#! /bin/sh # textfiles -- filter out non-text file names # # SYNOPSIS: Take a number of file names either as standard input # or as arguments on the command line. Print names of ones which are # text files back on standard output. # # AUTHOR: Gary T. Leavens [ -n "$echo" ] && set -x USAGE="Usage: $0 [file ...]" if test $# -eq 1 -a "$1" = '-?' then echo "$USAGE" >&2 exit 2 fi if test $# -eq 0 -o x"$1" = x'-' then if test -t 0 then echo "$0 : expecting file names:" >/dev/tty fi while read f do if test -f "$f" -a -r "$f" then case `file $f` in *" text") echo "$f" ;; *" script") echo "$f" ;; esac fi done else for f do if test -f "$f" -a -r "$f" then case `file $f` in *" text") echo "$f" ;; *" script") echo "$f" ;; esac fi done fi exit 0