![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| matching a letter in a word | Furqan_79 | Shell Programming and Scripting | 2 | 06-05-2008 01:45 PM |
| First letter of each Word from a line | maxmave | Shell Programming and Scripting | 5 | 04-15-2008 07:52 PM |
| return a word between two words | bryan | UNIX for Dummies Questions & Answers | 4 | 05-23-2006 01:56 PM |
| 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 09:35 PM |
| How to replace a word with a series of words in a file | brap45 | Shell Programming and Scripting | 2 | 02-21-2006 02:33 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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 |
|
||||
|
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 11:26 AM.. Reason: Show which lines are input |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|