Register
It is currently Mon Oct 20, 2014 7:02 am

grep multiple


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Sep 17, 2009 10:07 pm   

Joined: Sun Aug 02, 2009 1:17 am
Posts: 5
<some command giving text result> | grep -v "/Volumes/10/" | grep -v "/Volumes/6/" | grep -v "/Volumes/something/whatever/"
How to write this in a better way? (I mean, without using grep -v everytime and withoug piping it again and again)


Top
 Profile WWW  
 PostPosted: Fri Sep 18, 2009 7:03 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
Hi,

Can you give a sample of the input.
Can you show what should look like the output?
Can you tell exactly what's your purpose?


Top
 Profile  
 PostPosted: Fri Sep 18, 2009 7:24 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Something like this might work... if it doesn't add () around it and should work :P
Code:
<some command> | egrep "first|second|third|so on"


Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Thu Sep 24, 2009 10:42 am   

Joined: Sun Aug 02, 2009 1:17 am
Posts: 5
Thanks for your help.
sorry for the late reply. Somehow I did not get an email notification of the replies (i will recheck my forum preferences)
The reason why I did no show you my input/output is because I am using Mac OS. So you might not understand it easily.
I will try to explain though:
mdfind is a command in mac os which searches for files and folders.
It does not have ability to exclude specific locations. The result that the command returns is path of the files/folders. I use grep to remove the paths from the results that begins with a particular volume/folder etc.
So if my result looks like:
/volumes/7/folder1/file.jpg
/volumes/7/folderxyz/file.png
/volumes/8/folderabc/file.png
then to exclude results from volume 8 i use grep.

I have not tried the below code yet.
<some command> | egrep "first|second|third|so on"


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP