![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep question. | saurabhsinha23 | UNIX for Dummies Questions & Answers | 3 | 12-11-2007 01:58 AM |
| Question about GREP | Adriel | UNIX for Dummies Questions & Answers | 16 | 03-22-2007 08:03 AM |
| Another grep question | kingdbag | UNIX for Dummies Questions & Answers | 6 | 10-27-2006 01:56 AM |
| grep & sed question | der Kopf | Shell Programming and Scripting | 1 | 11-22-2004 04:49 AM |
| Grep question | eloquent99 | UNIX for Dummies Questions & Answers | 4 | 02-20-2003 10:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep question
hi all,
I need to grep for a string in a file which is in another string For Ex: This is the sample file sample.txt number 1234 name raje passwd 1234 date 123 service 75 service 23 I have made a unix command like this, i am not sure this is correct or wrong. If any better way please share with me $ grep -w "service" sample.txt > /tmp/supp_serv.txt | cat /tmp/supp_serv.txt | grep "75" > /tmp/sscode75.txt In the output (sscode.txt) i have to get ONLY "service 75" Thanks, -raje.. |
|
||||
|
Code:
grep "service" sample.txt | grep "75" > /tmp/sscode75.txt - this assumes one space Code:
grep "service 75" sample.txt > /tmp/sscode75.txt |
|
||||
|
Thanks for the fast reply.
I want to print the file name aswell in the sscode75.txt When i use the either one of the command ( like grep "service" sample.txt | grep "75" > /tmp/sscode75.txt ) i get only "service 75" in the sscode75.txt But i want to put the file name also like "sample.txt service 75" |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|