Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: is text file?
- X-seq: zsh-users 1040
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: unpingco@xxxxxxxxxxxx (Jose Unpingco), zsh-users@xxxxxxxxxxxxxxx (zsh)
- Subject: Re: is text file?
- Date: Sun, 28 Sep 1997 17:06:07 -0700
- In-reply-to: <9709282231.AA23791@xxxxxxxxxxxxxxxxx>
- References: <9709282231.AA23791@xxxxxxxxxxxxxxxxx>
On Sep 28, 3:31pm, Jose Unpingco wrote:
} Subject: is text file?
}
} I usually use PERL's -T in a function to check if a file is ASCII
} or binary. Is there a way to do this using zsh.
I'm sure Larry Wall will forgive me for saying that perl's -T is a hack.
It reads a chunk of the file and guesses whether the whole file is ASCII
based on the contents of that fragment.
Zsh's globbing uses only information from readdir() and stat()/lstat(),
and hopefully is going to stay that way.
An approximation might be (with extendedglob set):
% ls **/*~*(${~${(j/|/)fignore}})(.)
That is, all plain files that do not have extensions listed in `fignore'.
You could change (.) to (.^*) to omit executables, but that would also
omit most shell scripts.
(Somebody tell me why the extra ${~...} is needed in that expression.)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author