Outstanding responses....here they are...
UBE/medium: Re: behavior of ls
Tue, 6 Oct 1998 14:12:31 -0700
email@example.com (Kevin Sheehan - Uniq)
don't use csh - it obviously has a smaller limit on the size of the
argument list it is willing to expand.
Also, for large directories you might want to look at xargs...
Re: behavior of ls
Tue, 6 Oct 1998 12:55:03 -0700 (PDT)
Michael Hocke <firstname.lastname@example.org>
look into the man page of csh(1). At the end of the text you will find
paragraph headed with 'NOTES' which explains that 'the maximum number of
arguments to a command for which filename expansion applies is
Hope it helps.
Re: behavior of ls
Tue, 06 Oct 1998 13:36:18 -0600
For a good 'ls' command article, look here.
attached mail follows:
On Tue, 6 Oct 1998, Jose Montilla wrote:
> I have about 2000 plus files in a directory which gives me this output
> I have csh as my shell
> ls *
> Arguments too long
> change the shell to sh
> ls *
> and it lists the files
> in csh rm, echo, file, and maybe some more comes out with the same
> output (error).
> Any thoughts ?
I believe that before executing ls (rm/mv/etc) both csh and sh take
the command line, and processes it to turn all wild cards into actual
file and path names. The result is that your short command "ls *"
actually is converted into the line "ls file1 file2 file3 ...
file2000" etc before it ls executes. In other words, the ls
command isn't given a single parameter which is "*", rather it is
given a list of 2000 parameters, which is a list of all the filenames.
The problem arises when the list of files exceed the maximum line
length allowed by csh (I thinks it's up around 64k characters, but I
could be wrong about that).
You can verify this by trying the command:
the single quotes tell the shell not to convert the "*" into a list of
files. If you don't have a file with the name "*" then you should see
an error message that looks something like "*: No such file or
The solution is easy. Don't generate a list longer than the maximum
allowed line length;-) To do that, you generally use the xargs
program. In this case you would want something like:
ls | xargs -n 10 ls -alFd
what xargs(1) does (in this example) is collect 10 arguments (in this
case they are file names, since ls is feeding file names into the
pipe), then runs the command "ls -alFd <arg1> <arg2> ... <arg10>" for
each group of 10 arguments as read from the pipe.
Hope you find this useful,
Harvey M Wamboldt ^ E-Mail: email@example.com
MDA Inc 1000 Windmill Rd. Suite 60 ^ Fax: (902)468-2278
Dartmouth NS, B3B 1L7, Canada ^ Phone: (902)481-3531
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:50 CDT