[nflug] rm Limitations

Ken Smith kensmith at cse.Buffalo.EDU
Mon Jun 23 14:16:26 EDT 2008


On Mon, 2008-06-23 at 10:42 -0400, Robert Wolfe wrote:
> Hi all!
> 
> I have a BUNCH of files I need to clean out of a directory, but when I
> execute 'rm *' I get an "Argument list too long" error message.  Is
> there a way around this?  I get the same when mv'ing or cp'ing
> to /dev/null as well.
> 

A sometimes useful clarification: this isn't a limitation in rm (or mv
or cp).  It's a limitation in the shell which is what's doing the
wildcarding.  Some shells are more limited in this regard than others
(e.g. csh is much more limited than tcsh).  So if we suppose your shell
is currently csh, you could type in "tcsh" as a command which starts up
an interactive tcsh for you and you could give tcsh a try that way to
see if it can handle your argument list.

That said in addition to the xargs suggestion you could do:

	cd ..
	rm -rf directory-you-were-in
	mkdir directory-you-just-removed

(assuming there weren't any "dot" files in that directory you wanted to
preserve - they wouldn't have matched the wildcard...).

-- 
                                                Ken Smith
- From there to here, from here to      |       kensmith at cse.buffalo.edu
  there, funny things are everywhere.   |
                      - Theodore Geisel |




More information about the nflug mailing list