LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-30-2011, 03:11 AM   #1
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Rep: Reputation: Disabled
A problem about GREP


hi everyone.
I want to find all the lines which matches "aa" or "bb" in a certain file.
how could i write the grep clause?
for example:
cat filename|grep aa
can list lines contain aa.
but now I want to list lines contain "aa" or "bb" using a single clause.
thanks a lot.
 
Old 11-30-2011, 03:13 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289
Hi,

sounds like you want the -E (--exteneded-regexp) flag.
Code:
grep -E 'aa|bb' filename
Evo2.

PS. Also avoids the useless use of cat :-)
 
1 members found this post helpful.
Old 11-30-2011, 03:18 AM   #3
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Original Poster
Rep: Reputation: Disabled
I got it,thanks a lot.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem using grep -f zoeplankton Linux - Newbie 5 11-26-2010 07:03 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
grep problem spx2 Linux - Newbie 9 12-15-2005 02:22 AM
grep problem michaelsanford Linux - Software 2 05-20-2005 08:23 PM
Grep problem chup Linux - General 7 04-17-2004 01:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:34 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