[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Grepping only text files



Michael G Schwern wrote:

> $ file *
> FWP:        English text
> FWP.bin:    BinHex binary text, version 4.0
> Resume.doc: data
> Resume.txt: International language text
> foo.tar.gz: gzip compressed data, deflated, last modified: Thu Jun 10 20:48:49 1999, os: Unix
> phonetic:   directory
> send.txt:   ASCII text
> summarize:  perl script text
> 
> It is non-trivial to extract the filenames of text files from this
> (this can probably be done better):
> 
> file * | grep '\btext\b' | perl -ne 'print m/^([^:]+):/, "\n"' | xargs grep <pattern>


alias sgrep "file * | grep 'text$' | cut -f1 -d: |xargs grep "


now I have a sgrep command that will grep anything in the current
directory that file identifies as *text for the pattern specified.

And for my next trick, I'll juggle eggs.

________________________________________________________________________
  David Nicol 816.235.1187 UMKC Network Operations david@news.umkc.edu
     "on a 80x24 character cell terminal in a damp basement, under
       a bare light bulb, perched atop a backless wooden stool."

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org