![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| matching a letter in a word | Furqan_79 | Shell Programming and Scripting | 2 | 06-05-2008 10:45 AM |
| First letter of each Word from a line | maxmave | Shell Programming and Scripting | 5 | 04-15-2008 04:52 PM |
| return a word between two words | bryan | UNIX for Dummies Questions & Answers | 4 | 05-23-2006 10:56 AM |
| how to find capital letter names in a file without finding words at start of sentence | kev269 | Shell Programming and Scripting | 1 | 04-10-2006 06:35 PM |
| How to replace a word with a series of words in a file | brap45 | Shell Programming and Scripting | 2 | 02-20-2006 10:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
How to filter the words, if that word contains the expected letter
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 |
| Forum Sponsor | ||
|
|
|
|||
|
Your example is not very clear. You mean, extract and print those tokens which contain the string "abc"?
Code:
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
Last edited by era; 03-18-2008 at 07:26 AM. Reason: Show which lines are input |