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-22-2010, 09:37 AM   #1
LQ Newbie
Registered: Sep 2010
Posts: 11

Rep: Reputation: 0
Grep with two input.

Hi There,

Is there any way i can pass two / three values to grep. Basically i want to list the lines in the file with three different values. Currently I'm using three grep to get my work done.

EG: more Filename | grep text1 | grep text2 | grep text3
Old 09-22-2010, 09:50 AM   #2
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Use 'egrep'.
Old 09-22-2010, 10:06 AM   #3
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
It's not clear what you want to achieve. If you want to match ALL three value on each line but in any order, then your command line is OK; if you have a constant order, or if the number of alternatives is reasonable, you can of course write a single regex to match everything.



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
Bash: using file as input for grep/tail and then some.. sleipnir Programming 5 06-18-2009 04:51 PM
anything piped to grep returns "(standard input)"... why? allohakdan Linux - Software 8 09-28-2008 01:02 PM
shell script having multiple grep statements-I want input file to be read only once mukta9003 Linux - Newbie 4 08-27-2008 12:58 AM
grep input/output error on slackware 10.1 install dpp777 Linux - Newbie 1 09-07-2005 09:25 AM
utf , standard output / input and grep too Fascistchicken Linux - Software 2 11-05-2004 08:52 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 AM.

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