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: Dave Gotwisner
Subject: Re: ls options: accept stdin, and list files except for...
Date: Mon, 15 Sep 2003 12:00:18 -0700

Dan Heller wrote:

> 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.
>

Another "standard" way to solve this is to have an option that is a file
that contains options.
This is fairly standard on lots of systems (I have used it on Dos, Windows,
VMS, RT-11, RSX-11,
RSTS, and other OS's over the years.  GCC (actually the
GNU LD command) uses this also,
and in fact, the standard VxWorks build environment relies on it.  If it is
implemented as a standard
option (lets say @, to be consistent will all the other operating systems),
GETOPT can be modified
to deal with it transparently.  Of course, to be safe across operating
systems and not break existing
programs, it would have to clone argc/argv.

    Dave





reply via email to

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