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 09-09-2010, 04:59 PM   #1
Registered: Feb 2007
Posts: 386

Rep: Reputation: 30
how to grep 2 words at the same time

I want to grep any line with "john" or "jack". How to do that?
I tried

grep john | grep jack

but it didn't work
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-09-2010, 05:19 PM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
grep -e john -e jack

or (better)

egrep '(john|jack)'

What you tried was actually a pipe from one grep to the next.
2 members found this post helpful.
Old 09-09-2010, 05:25 PM   #3
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354 is your friend. Most questions that you may have are already answered. For example:


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, sed, awk or tr - searching words in a string hal8000b Programming 2 03-06-2009 09:04 PM
Grep an entire file but must contain multiple words wakeboarder3780 Linux - Newbie 10 02-19-2009 05:46 PM
Grep words and paste is on the same line say_hi_ravi Programming 7 10-31-2008 07:56 AM
GREP - reg exp to find words ending with .V and .TO vikram_cvk Linux - Server 5 12-22-2006 02:47 PM
Can grep filter out words? extrasolar Linux - General 1 07-20-2006 04:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:57 PM.

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