![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do i pattern match a field with awk? | someone123 | Shell Programming and Scripting | 4 | 06-03-2008 05:08 AM |
| how to use pattern match with grep | rei | UNIX for Dummies Questions & Answers | 5 | 01-05-2007 12:33 AM |
| Match portion of the filename | mpang_ | Shell Programming and Scripting | 1 | 06-27-2006 03:20 AM |
| pattern match and substitution, can you help? | frustrated1 | Shell Programming and Scripting | 4 | 02-20-2006 04:48 AM |
| How to pattern match on digits and then increment? | sdutto01 | Shell Programming and Scripting | 2 | 08-11-2005 11:46 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
To identify filename in which having match PATTERN
Hi,
Any idea to identify bunch of files( gz format) in which having match PATTERN wanted and print out those files ? Regards, |
| Forum Sponsor | ||
|
|
|
|||
|
*bling* Useless Use of Glob in Backticks! Also the "ls -l" actually is a rather grave error. You could simply drop the -l, but the whole ls is redundant.
Code:
for i in *.gz do gzip -dc <$i | fgrep "string" >/dev/null && echo $i done zgrep is actually fairly buggy for stuff like this; other than that, it is the proper answer. It's a fairly small shell script so you could simply find it in Google and copy to your $HOME/bin |
|||
| Google The UNIX and Linux Forums |
| Tags |
| linux, solaris, ubuntu |
| Thread Tools | |
| Display Modes | |
|
|