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

Re: Argument List too Long

On 02Jun2010 09:19, cliff here <c4ifford gmail com> wrote:
| basically it takes stdout and you pipe to stdin ... but it basically handles
| each argument one at a time instead of in a batch.
| find /tmp -name core -type f -print | xargs /bin/rm -f

The OP was wanting:

  mv files... target-dir

xargs puts the filenames at the _end_ of the command line, and thus
doesn't play nice. We can leave aside the horrible quoting problems it
has, since he can get away with find's -print0 predicate and xargs' -0

Probably the easiest fix is a small wrapper script for mv which mangles
the line to work around xargs, eg a script called "move-to.sh" thus:

  exec mv -- ${1+"$@"} "$target/."

and then call:

  find . -type f -print0 | xargs -0 sh move-to.sh the-target-dir

and he would be away. Unless he has a directory tree structure to
preserve, in which case more work is needed.

And BTW, try to lose the horrible habit of using the -f option to rm; it
is usually not needed. I know that many distros ship with "rm" aliases
to "rm -i", which teaches people to reach automatically for -f to avoid
much pain, but it is better to get rid of the alias, not to turn off all
the sanity checks by habit. (And in a script the aliases are not in
play, so you don't need -f there unless you really do not want to notice
when you issue lots of totally bogus rm commands.)

Cameron Simpson <cs zip com au> DoD#743

The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads
and ban radars I'll be the first in line......AMCN

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