Solved

Grep- result into sorted file

Posted on 2013-01-26
4
510 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
  • 2
  • 2
4 Comments
 
LVL 84

Assisted Solution

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

see
man grep
and
man sort
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 250 total points
Comment Utility
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
Comment Utility
0
 
LVL 37

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now