zsh-users
 help / color / mirror / code / Atom feed
From: Greg Badros <gjb@cs.washington.edu>
To: "Bart Schaefer" <schaefer@brasslantern.com>
Cc: Greg Badros <gjb@cs.washington.edu>, zsh-users@math.gatech.edu
Subject: Re: is text file?
Date: 30 Sep 1997 13:02:37 -0700	[thread overview]
Message-ID: <qrren667eoy.fsf@demille.cs.washington.edu> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Tue, 30 Sep 1997 11:56:12 -0700"

I use this in ~/zsh-fns/only-text-files:

# Filter out non-text-files from the argument list
# Usage: grep -c foo `only-text-files *`
file -f =(for i in "$@"; do print $i; done) |\
   awk -F: '{name = $1; $1 = ""; if ($0 ~ / text( |$)/) { print name }}'

I think it's important to use "file", as that is the system-supported way
of testing whether a file contains text.  The file man page also
strongly encourages the use of the string "text" in files which are
text, so it's pretty reliable to use the regexp (one possible exception
is postscript files).

Greg J. Badros
gjb@cs.washington.edu
Seattle, WA  USA
http://www.cs.washington.edu/homes/gjb


      reply	other threads:[~1997-09-30 20:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-28 22:31 Jose Unpingco
1997-09-29  0:06 ` Bart Schaefer
1997-09-29 16:25   ` Greg Badros
1997-09-29 17:44     ` Bart Schaefer
1997-09-29 21:28     ` TGAPE!
1997-09-30  3:53       ` Bart Schaefer
1997-09-30 16:19       ` Greg Badros
1997-09-30 18:56         ` Bart Schaefer
1997-09-30 20:02           ` Greg Badros [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=qrren667eoy.fsf@demille.cs.washington.edu \
    --to=gjb@cs.washington.edu \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).