in reply to Finding names in files
Now, addressing your code, couple starting points: note that $. (see perlvar) can be used instead of $count ; instead of string matching 'Dave' (which is why the case has to be exact), use a regular expression of /dave/i (or maybe /\bdave\b/i) -- see perlre for tons of regexp info.#bash: for f in `find /tmp/files/`; do head -20 $f | grep -q -i dave && echo +$f >> list.txt ; done perl -lne 'do { print $ARGV; last } if /DAVE/i; last if $. == 20' `fi +nd /tmp/files` >> list.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding names in files
by gzayzay (Sexton) on Mar 29, 2006 at 17:36 UTC | |
by davidrw (Prior) on Mar 29, 2006 at 17:39 UTC |