a question about GREP

Ben Scott dragonhawk at gmail.com
Fri Mar 23 18:15:55 EDT 2007


On 23 Mar 2007 17:01:40 -0400, Kevin D. Clark <kevin_d_clark at comcast.net> wrote:
> Here is how I would do this:
>
> find your-dirname1 your-dirname2 -name \*out\* \
>    -exec perl -e 'undef $/;
>                   $filename=$ARGV[0];
>                   $_=<>;
>                   exit(!(-T $filename && /\bzip\b/))' \{\} \; -print \
>      >zip.txt

  Holy crap!  Where's Perl's oft-decried extreme conciseness?  ;-)

  I much prefer the all-in-one approach:

grep -lwir --include=\*out\* . > zip.txt

  Yah, the find command is very useful, since it's generic, and thus
works in very complicated situations, when nothing else will.  But for
more common cases, the convenience features of modern *nix tools
really do save a lot of work.  :-)

-- 
"One day I feel I'm ahead of the wheel / And the next it's rolling over me"
                                                  -- Rush, "Far Cry"


More information about the gnhlug-discuss mailing list