Re: newbie - questions about "rm"



On 2006-12-27, dave8421@xxxxxxxxxxx wrote:
Hi,

I've read that 'xargs' should be used with 'rm' when using a list of
files too large for 'rm' to process.

I'm wondering why 'rm' doesn't just accept a list of files as a command
line argument,

It does, but if therre are a lot of files, it may exceed the
system limit.

Also, if the output is redirected from another command, is there a lot
of overhead using a program like xargs, since it is calling the program
multiple times? Is this considered to be efficient way of processing
arguments, or is there a better way?

xargs puts as many arguments on the command line as the system
will allow, so that the command is called the fewest possible
number of times.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: Command line to remove duplicate files?
    ... Ohmster wrote: ... what xargs does? ... So what xargs does is pretty much pass on large numbers to the command ... Put "messageforohmster" in message body ...
    (alt.os.linux)
  • Re: Pipe output from find to mv
    ... I would suggest you to go with gnu xargs instead of -exec ... At first glance, the find command above was rather complicated, not to ... though- GNU find and everyone else's. ... we must use another command to sort such output-a ...
    (comp.unix.shell)
  • Re: Neophyte: ls with wildcards
    ... There's two ways to provide data for a command -- either as a command ... What xargs does is it reads data from standard input and then looks ... would lead to xargs eventually executing "ls /bin". ... to argument lists ...
    (comp.unix.shell)
  • Re: find -exec surprisingly slow
    ... deleting files from a directory which has 400K filenames in it, ... mv usermail usermail.bigspam ... The thing to use is the '-J' option of xargs. ... a single `mv' command as possible. ...
    (freebsd-questions)
  • How to use xargs with a shell redirect
    ... command with redirects in it? ... like a perfect opportunity for the shell (BASH shell, ... to do this with xargs... ...
    (comp.unix.shell)