Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

Grep- result into sorted file

Hello Experts!

I am learning basics of linux.

I have got a file with lots of lines.

I know how to find proper lines using grep but I do not know how to create output file with my result which would be sorted.

Could you please give me any hint about it?

Thank you!

panJames
0
panJames
Asked:
panJames
  • 2
  • 2
2 Solutions
 
ozoCommented:
grep -options pattern file | sort -options > output

see
man grep
and
man sort
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
As you're learning, one of the basics is that you can send output of one command to the next using the pipe character, like this:

cat file
cat file | grep pattern
cat file | grep pattern | sort

and then redirect the output to a file by adding the redirect > character:

cat file ...   > outputfile
0
 
ozoCommented:
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
@ozo - cat is just an example in my general explanation, I could have written strings instead...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now