in reply to Re: what regular expression do I need?
in thread what regular expression do I need?
If the lines can only begin with IMO then:cat file1 | perl -e 'while(<>){ next if !/IMO/; print $_;}'
If case is not important then:cat file1 | perl -e 'while(<>){ next if !/\bIMO/; print $_;}'
If you have multiple words to search for, then create another file named file2 and enter the search words:cat file1 | perl -e 'while(<>){ next if !/\bIMO/i; print $_;}'
From the unix command-line... file2 is the list of words to search for from lines in file1... Note: you may have to run "dos2unix file2" to remove LF/CR or use chomp somehow...vi file2 apple orange banana grep -f file2 file1
|
|---|