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 09-09-2010, 03:59 PM   #1
ufmale
Member
 
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, 04:19 PM   #2
slakmagik
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, 04:25 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
www.google.com/linux is your friend. Most questions that you may have are already answered. For example: http://linux.byexamples.com/archives...ds-and-not-or/
 
  


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

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

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