Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-10-2009, 03:45 AM   #1
Senior Member
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
grep file

I would like to ask if I want to grep somthing .

I know the command " ll |grep Jun" can grep file with Jun , if I want to grep file with May and Jun , what can i do ? thx
Old 06-10-2009, 03:46 AM   #2
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Yes you can use grep to search through files. Read the man page..

Simple example: grep "foo" stuff - this searches for the string "foo" in the file "stuff".
Old 06-10-2009, 03:50 AM   #3
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
Just use the "man" command to find out things like this.
man grep
gives this information:
Two regular expressions may be joined by the infix operator |; the
resulting regular expression matches any string matching either alternate
Old 06-10-2009, 04:43 AM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Originally Posted by ust View Post
I would like to ask if I want to grep somthing .

I know the command " ll |grep Jun" can grep file with Jun , if I want to grep file with May and Jun , what can i do ? thx
Do you mean "May and Jun", or possibly "May OR Jun".

egrep '(May|Jun)' filename

egrep 'May' filename | egrep 'Jun'

Note the two very different meanings of the "|" operator.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
grep file ust Linux - Newbie 4 03-06-2009 04:33 AM
grep for string in file after a certain part of the file B-Boy Programming 6 02-18-2009 07:49 AM
can't grep file ust Linux - Software 3 01-07-2008 06:03 AM
How can I grep text from file? @ngelot Linux - Software 6 06-13-2007 04:44 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:51 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration