Hi,
I am trying to filter the words from a file which contain 'abc'. But I am unable to. Could any one help me.
For eg: The file contents are
123ab 12hnj1 123abc456 123cgbcahjkf23 23134abchfhj43 gc32abc abc1 2abc3 sd uiguif fhwe 21242 uh123 jkcas124d123 u3hdbh23u ffsd8
Output expecting is :
123abc456 23134abchfhj43 gc32abc abc1
2abc3
Regards
Venu
system
March 18, 2008, 11:23am
2
Your example is not very clear. You mean, extract and print those tokens which contain the string "abc"?
vnix$ perl -lane 'print join (" ", grep { /abc/ } @F)'
foo fabci canbc cabca fnabca 123ab23c babco swill <- input
fabci cabca fnabca babco
snort abc foo <- input
abc
^D
Do you want to preserve newlines? (This solution does.) What about spaces between the tokens? (This solution normalizes them to one space between each.)
With Z-Shell:
print ${(M)$(<file)##*abc*}
Hi era,
Your solution is in perl, I need it in unix.