Hi..
How to search for multiple words in a single line using grep?.
Eg: Jack and Jill went up the hill
Jack and Jill were best friends
Humpty and Dumpty were good friends too
----------
I want to extract the 2nd statement(assuming there are several statements with 'friends' pattern)..so I want to match the all the patterns
like 'Jack', 'Jill' and 'friends'
Thx !
Anduzzi
You have to use egrep for that, for ex:
egrep -e "Jack|Jill|friends"
you can use awk also
awk '/Jack/&&/Jill/&&/friends/{print $0}' filename
this will give the lines containing Jack or Jill or friends
i don't think anduzzi want that
Hi guys...thx for the responses...really appreciate !
But none is working in my scenario..
well here is what I have practically:
mp ifile PDEWS001.S1_C1_Dim_Input_File 'file:'"${INPUT}"'/ssim_svc_type.csv'
mp ifile PDEWS001.S2_C4_CURRENT 'file:'"${DATA}"'/'"${AB_GRAPH_NAME}"'_s2_c4_current.dat'
well....I don't want the second line here...I just need the entire line that has the combination of both 'ifile' and 'INPUT' but not 'ifile' and 'DATA'.
I tried both of the above suggested egrep and awk and it doesnt work.
please suggest !
-Anduzzi
Well you could do some thing like
awk '/ifile/&&/INPUT/ {print $0}' FILENAME|grep -v DATA
no need for 'grep' and 'print $0':
awk '/ifile/&&/INPUT/ && !/DATA/' FILENAME
Thanks guyss for all the help!
It works and I got what I want...
Guys..here is one more logical question I was working out...got some solution with me but would like to listen to various perspectives..
Scenario:
'file:'"${DATA}"'/input/dpi/device_type.csv'
'file:'"${DATA}"'/input/manual/arptgroup.csv'
'file:'"${DATA}"'/input/manual/fuel/costcentre.csv'
'file:'"${DATA}"'/input/spt/deduce.csv'
I wanna pick just the file name part out of all these possibilities....
device_type.csv
arptgroup.csv
costcentre.csv
deduce.csv
Appreciate your ideas !
Thx !
Anduzzi
anduzzi
January 29, 2009, 12:33pm
10
Scenario:
'file:'"${DATA}"'/input/dpi/device_type.csv'
'file:'"${DATA}"'/input/manual/arptgroup.csv'
'file:'"${DATA}"'/input/manual/fuel/costcentre.csv'
'file:'"${DATA}"'/input/spt/deduce.csv'
I wanna pick just the file name part out of all these possibilities....
device_type.csv
arptgroup.csv
costcentre.csv
deduce.csv
Appreciate your ideas !
Please don't bump up posts - it's against the rules .
How do I grep multiple files for multiple entries?
I have a range of consecutive daily files that I want to search to find any instance of multiple non sequential numbers.
Is this possible?