www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/22/09:16:38

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <4309D026.8000702@byu.net>
Date: Mon, 22 Aug 2005 07:16:22 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Morten Kjarulff <MKJ AT dk DOT ibm DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: bash: /usr/bin/rm: Argument list too long
References: <OF2DB26951 DOT D12307CF-ONC1257065 DOT 0045672A-C1257065 DOT 00472A45 AT dk DOT ibm DOT com>
In-Reply-To: <OF2DB26951.D12307CF-ONC1257065.0045672A-C1257065.00472A45@dk.ibm.com>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Morten Kjarulff on 8/22/2005 6:56 AM:
> Hi,
> 
> If I try to rm many files, or fewer files with long names I get "bash:
> /usr/bin/rm: Argument list too long". Can anyone tell the limits?

The limits are pretty low if you are using Windows mechanisms, although I
don't know the exact limit (they can be increased by mounting /bin as
cygwin-executable, but even then still have limits).  But generally, if
you are trying to pass that much data on the command line, there is
usually a better solution that does not even expand the wildcard.

> 
> Is the solution something like "for file in * ; do rm $file ; done"?

It is, if you don't mind doing it one file at a time.

If you don't mind deleting the directory, there is always this (let rm do
the recursion, instead of calling out every file yourself):
cd .. && rm -R tmp

Or if you want to delete as fast as possible without surpassing
command-line limits, there is this (it works, since echo is a shell
builtin, and since xargs is getting the list from stdin and not the
command line, then calling rm as many times as needed with a group of
filenames as command-line arguments):
echo * | xargs rm

By the way, this is not a cygwin-specific problem, it is just that cygwin
tends to have a smaller command-line limit than many other platforms.

> 
> same thing for ls:
> mkj008 AT mcmkj01w /tmp
> $ ls *

See the coreutils FAQ - 'ls' is MUCH more efficient than 'ls *', and does
the SAME THING!

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

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net
volunteer cygwin coreutils maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDCdAm84KuGfSFAYARAnHtAJ9x3fynt113ri0ZYSFxmLkrYKT4rwCfffhs
zLXtaL1CGL4Yu3aekRGYH14=
=b+Y1
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019