help-gnu-utils
[Top][All Lists]
Advanced

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

Re: Command failure: Too Many Files (rm, ls, tar)


From: Bob Proulx
Subject: Re: Command failure: Too Many Files (rm, ls, tar)
Date: Tue, 15 Apr 2008 10:55:35 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

Browder, Tom wrote:
> Last week I started getting errors indicating there were too many files
> for the command (rm *, ls *, tar cvzf xfer.tgz *) to continue.
> ...
> Is there a magic number limit on those commands?
> Or am I doing something wrong.

You are running into the kernel's ARG_MAX limitation.  Please see this
reference for more information.

  http://www.gnu.org/software/coreutils/faq/#Argument-list-too-long

> I regularly copy the files to a transfer directory, cd to that
> directory, and tar them and gzip them (tar cvzf xfer.tgz *) to take
> them to another site.

For your 'tar' case you can avoid the argument expansion entirely
simply by giving '.' as the argument.

  tar cvzf xfer.tgz .

For 'rm *' I would normally either simply remove the entire directory
with 'rm -rf ./dir' or use 'find' like this:

  find . -exec rm {} +

For 'ls *' there is no need of the '*'.  Just use ls.  Actually using
'ls *' is inefficient because the shell expands the * to match every
filename in the directory and ls then lists it.  But the entire
purpose of ls is to list directories.  So 'ls *' does the same work
twice while 'ls' does it once.  Better to simply use 'ls'.

  ls

Bob




reply via email to

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