![]() |
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 |
| How to grep / zgrep to output ONLY the matching filename and line number? | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 05:33 PM |
| filename to string | cprognew | High Level Programming | 1 | 07-22-2007 05:08 PM |
| how can i add/modify filename after output? | happyv | Shell Programming and Scripting | 3 | 10-03-2006 05:25 AM |
| Appending to filename a string of text grep finds | HLee1981 | Shell Programming and Scripting | 3 | 09-06-2005 02:44 PM |
| Losing filename in grep output | netguy | Shell Programming and Scripting | 6 | 04-27-2004 11:39 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
grep string and output filename
Hello,
I have over 200 files and some of them have the string like "John price $200". I would like to grep the string. Then output the filename which found the string. I have the following script, but it ONLY output the string echo Please input list file name: read listn for file in `cat $listn.txt` do cat $file |grep "John price $200" done expect output: filename: XXXXXX found string: John price $200 thx, happyv |
|
||||
|
not sure what OS you are using, but grep -l (that's a lowercase L) will show just the filename, not the line that matches. Do a man on grep and it should tell you how to get just the name, or tell us the os and we might be able to help some more.
|
|
||||
|
thx..but how can I check my OS in unix?
|
| Sponsored Links | ||
|
|