Re: newbie - questions about "rm"



dave8421@xxxxxxxxxxx enlightened us with:
I've read that 'xargs' should be used with 'rm' when using a list of
files too large for 'rm' to process.

Mostly it's a limit of the shell.

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

It does. However, if you have a directory with 1000000 files in it,
you can't just do "rm *" do delete them all. xargs will take the
filenames from stdin and feeds them to the "rm" command in bite-size
chunks.

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?

That depends on the program that's being called multiple times. I
wouldn't worry about it until you notice it becoming a problem.

Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
.



Relevant Pages

  • 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)
  • Re: how to delete files within entire directories?
    ... for f in $; do echo $f; done ... sh-compatible shell does the same. ... The amount of output at least /bin/sh is willing to collect on command ... >>results into xargs. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: [opensuse] /bin/rm: Argument list too long
    ... though I have my shell configured to pass non-matching glob ... to whatever command you ran with xargs. ... lists, there's really no reason to do so and I know of no programs that ...
    (SuSE)
  • Re: Controlling (La)TeX
    ... I am fully aware of TeX's command line interface. ... The bash shell, and Windows CMD.EXE. ... shell might 'press the ^C button' multiple times. ...
    (comp.text.tex)
  • Re: tcsh being dodgy, or pipe code ishoos?
    ... Say the shell you run the above command is 10. ... exec xargs. ... Since 12 is stil around and a child of 11, ...
    (freebsd-current)