a question about GREP

Jerry greenmt at gmail.com
Mon Mar 26 11:38:31 EDT 2007


Hi,

Thank you for all your help and time. I really appreciate it.



On our server, which runs "Red Hat Enterprise Linux AS release 3 (Taroon
Update 8)"

Lloyd (python at venix.com)'s solution works:

find -type f -name '*out*' | xargs grep -wli zip > zip.txt

Question: "-type f" limits to "regular file", does the so-called "regular
file" strictly mean "plain text files"?


Also, solution from Ben (w/ adding search pattern, which is "zip") and Bill
(w/ moving "zip" ahead of ".") works:

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

-------------------------------------------------------

Steven's solution (listed below) only partially works, for reasons I don't
know. By "partially", I mean his solution can only find SOME files matching
the search criteria.

 find . -type f -name \*out\* | \
 xargs file | \
 awk '/ASCII/ { sub(/:/, ""); print $1}' | \
 xargs grep -l zip > zip.txt


-----------------------------------------------
Kevin, in your solution (listed below), why are there 2 directory names are
used? Could you please explain a bit to me? Thank you.


find your-dirname1 your-dirname2 -name \*out\* \
  -exec perl -e 'undef $/;
                 $filename=$ARGV[0];
                 $_=<>;
                 exit(!(-T $filename && /\bzip\b/))' \{\} \; -print \
    >zip.txt


BTW, yes, I'm serious about the "plain text files" part.

And thank you for your favorite alias, I've not tested though.

----------------------------------------------
Bill, your another solution (listed below), based on Steve's, doesn't work
:-(

find . -name '*out*' -exec file '{}' '|' grep -q ASCII ';' -print0 \
    | xargs -0 grep -wli zip > zip.txt



Again, thank you guys all!

Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20070326/4cc7eb89/attachment.html


More information about the gnhlug-discuss mailing list