LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-10-2009, 04:45 AM   #1
ust
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, 04:46 AM   #2
Nylex
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, 04:50 AM   #3
jdkaye
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.
Code:
man grep
gives this information:
Quote:
Alternation
Two regular expressions may be joined by the infix operator |; the
resulting regular expression matches any string matching either alternate
expression.
cheers,
jdk
 
Old 06-10-2009, 05:43 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
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".

OR:
egrep '(May|Jun)' filename

AND:
egrep 'May' filename | egrep 'Jun'

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


Reply


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 05:33 AM
grep for string in file after a certain part of the file B-Boy Programming 6 02-18-2009 08:49 AM
can't grep file ust Linux - Software 3 01-07-2008 07:03 AM
How can I grep text from file? @ngelot Linux - Software 6 06-13-2007 05:44 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM


All times are GMT -5. The time now is 08:48 AM.

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