Solved

Grep- result into sorted file

Posted on 2013-01-26
4
564 Views
Last Modified: 2013-01-28
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
Comment
Question by:panJames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 250 total points
ID: 38821634
grep -options pattern file | sort -options > output

see
man grep
and
man sort
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 250 total points
ID: 38823083
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
 
LVL 84

Expert Comment

by:ozo
ID: 38823274
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 38823634
@ozo - cat is just an example in my general explanation, I could have written strings instead...
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question