bug-fileutils
[Top][All Lists]
Advanced

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

Re: ls options: accept stdin, and list files except for...


From: Dan Heller
Subject: Re: ls options: accept stdin, and list files except for...
Date: Sun, 14 Sep 2003 22:48:53 +0000

On Sep 14,  8:15pm, Richard Dawe wrote:
>     find . ! -type d ! -name '*.html' | xargs ls [OPTIONS]
> 
> (Find all files that are not directories and not called '*.html'.)

There is one major issue here, and one mnor one. The major problem is
that the output for one command may be too long to be used as the
command for whatever xargs launches.  In my bug report for "du -s",
for example, "locate" (or "find") is used to get a list of all jpg
files in a filesystem to total up the disk usage from those files.
However, replace find with "grep -l" or anything else that may
produce an arbitrarily long list of filenames that needs to be used
as input to the next command, and you may exceed the max argument
length. (I do regularly.)

I can't use xargs, backticks, or even a shell script that saves the
list and launches things separately because of the inherent problem
that the command can't be executed if the arg list is too long.

IMHO, the simplest solution to this, and the most elegant, albeit not
one that would win an obfuscated coding contest, is to simply enhance
command-line utils to read the list of filename arguments on stdin.

----------------------------
Now, w.r.t my bug report on "ls" having an option to list a directory's
contents while omitting the list of files its given on it command line
(or stdin), the "minor" problem is that it's a lot of overhead for a
conceptually simple abstraction that can be more efficiently implemented
within ls.  Yes, the theory that unix should be a collection of very
small lightweight utilities that can be strung together with pipes is a
great foundation and it should be preserved.  Combine that with the
vastly efficient and superior pattern-processing tools and libraries at
our disposal that didn't exist before, and one can argue for a more
pallatable proposal for ls: --omit "pattern" where the argument is a
regex pattern. This way, you can do

    ls -omit '*.html' -omit '*.bak' -dF dir1 dir2

This would be faster and more lightweight than having to launch two
instances of ls (or find), a grep, and an xargs to do the same thing.

-- 
--dan
http://www.danheller.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]