Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Grep- result into sorted file

Posted on 2013-01-26
4
Medium Priority
?
582 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 1000 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 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

610 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