Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: what regular expression do I need?

by tbone654 (Beadle)
on Apr 19, 2013 at 04:33 UTC ( #1029454=note: print w/replies, xml ) Need Help??

in reply to Re: what regular expression do I need?
in thread what regular expression do I need?

How about...
cat file1 | perl -e 'while(<>){ next if !/IMO/; print $_;}'
If the lines can only begin with IMO then:
cat file1 | perl -e 'while(<>){ next if !/\bIMO/; print $_;}'
If case is not important then:
cat file1 | perl -e 'while(<>){ next if !/\bIMO/i; print $_;}'
If you have multiple words to search for, then create another file named file2 and enter the search words:
vi file2 apple orange banana grep -f file2 file1
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...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029454]
[marto]: #deletefacebook
[LanX]: well try to find my profile xD
[marto]: derp
[marto]: I've never had an account, and wouldn't visit the site
LanX having only a fake profile is hard if a flirt asks to befriend you
[erix]: "surveillance companies" have been rebranded as "social media"
[LanX]: I'm using whatapp though :-/
[LanX]: Snowden remins me of Evan Spiegel (... start of a new conspiracy theory)
[LanX]: yes! The same person!

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-03-19 15:27 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.