LinuxQuestions.org
Visit Jeremy's Blog.
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 10-13-2007, 09:37 AM   #1
gil_r21
LQ Newbie
 
Registered: Oct 2007
Posts: 4

Rep: Reputation: 0
grep command - 3 different expresions


Hi
I have a problem:
I am trying to create a single grep command that checks if 3 different expirations are in a specific file.

right now what I am using is 3 different commands as follows:

grep -r -l "Error can't open" x/*.txt
grep -r -l "rsync error" x/*.txt
grep -r -l "can't aquire" x/*.txt

But as I said I want them all in one command to make it easier for me.

please advise
 
Old 10-13-2007, 09:54 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Use egrep:
Code:
 egrep -r -l "Error can't open|rsync error|can't aquire" x/*.txt
This shows the file name if it contains any one of the three messages.

Last edited by Disillusionist; 10-13-2007 at 09:56 AM.
 
Old 10-13-2007, 11:27 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You can also specify multiple expressions with the -e option, e.g.
Code:
grep -rl -e "I hope" -e "This isn't" -e "Homework" x/*.txt

Last edited by matthewg42; 10-13-2007 at 01:08 PM.
 
Old 10-14-2007, 04:32 PM   #4
gil_r21
LQ Newbie
 
Registered: Oct 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks guys

Hi
Thanks it works
helped me alot
 
  


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
Help Use Grep Command, Thanks! zzytech Linux - Newbie 2 04-06-2006 12:37 AM
Bash: How can i use variables for grep regular expresions ? landuchi Linux - General 4 01-22-2006 12:57 AM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 02:01 AM
Regular Expresions on C++ poeta_boy Programming 7 06-18-2004 01:00 AM
Help With GREP Command juliettree Linux - Newbie 3 04-08-2004 09:44 AM


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