LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 03:45 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
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
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, 03:50 AM   #3
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

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, 04:43 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:52 PM.

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
Open Source Consulting | Domain Registration