LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 01-16-2007, 07:35 PM   #1
Kropotkin
Member
 
Registered: Oct 2004
Location: /usr/home
Distribution: Fedora, Mint, FreeBSD, Android
Posts: 346

Rep: Reputation: 31
grep CLI syntax: how to find A OR B?


I can't get figure out how to alternation to work on the command line. Something like this doesn't work:

$ grep \(the\|and\) somefile.txt

nor this:

$ grep "(the|and)" somefile.txt

What's the secret?
 
Old 01-16-2007, 07:44 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Try:
Code:
egrep 'the|land' somefile
 
Old 01-16-2007, 09:09 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
What anomie said, or you could try:
Code:
grep -e the -e and somefile.txt
 
Old 01-16-2007, 09:45 PM   #4
Kropotkin
Member
 
Registered: Oct 2004
Location: /usr/home
Distribution: Fedora, Mint, FreeBSD, Android
Posts: 346

Original Poster
Rep: Reputation: 31
Just what I was looking for, thanks.
 
  


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 script/syntax carriehoff Linux - Newbie 6 08-31-2006 01:13 PM
need help with find syntax stefaandk Linux - General 4 07-12-2006 05:48 PM
Grep syntax questions Phaethar Linux - General 4 04-11-2005 09:34 AM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
help me find grep-2.5.1 shanenin Linux - Software 1 01-23-2004 09:01 PM


All times are GMT -5. The time now is 09:12 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration