From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16175 invoked from network); 30 Sep 1997 20:07:21 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 30 Sep 1997 20:07:21 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id QAA20391; Tue, 30 Sep 1997 16:03:07 -0400 (EDT) Resent-Date: Tue, 30 Sep 1997 16:02:07 -0400 (EDT) To: "Bart Schaefer" Cc: Greg Badros , zsh-users@math.gatech.edu Subject: Re: is text file? References: <199709292128.VAA10542@dal-tsa12-29.cyberramp.net> <970930115613.ZM17003@candle.brasslantern.com> From: Greg Badros Date: 30 Sep 1997 13:02:37 -0700 In-Reply-To: "Bart Schaefer"'s message of "Tue, 30 Sep 1997 11:56:12 -0700" Message-ID: X-Mailer: Gnus v5.4.65/Emacs 19.34 Resent-Message-ID: <"8BGYL2.0.dy4.-gLCq"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1054 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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