in reply to Re: File::Find considered hard?
in thread File::Find considered hard?

Just an aside:

You can't do everything you'd want to do with find -print0 | xargs -0. For example, to rename all files to $file.bak, you'd have to write a shell "for" or "while" loop.

At least with GNU xargs, that's not true. There's an option -i which lets you specify a placeholder in the commandline passed to xargs (which can be specified but defaults to {}), so a xargs solution for the example above would be

find $FOO -print0 | xargs -0i mv {} {}.bak

Of course this loses the main advantage of xargs: you are back to spawning one mv process per file, so you might as well just use the portable -exec interface.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: File::Find considered hard?
by etcshadow (Priest) on Mar 15, 2004 at 07:56 UTC
    Perfectly valid, but I don't think it does anything to damage the point I was trying to make.

    I mean... even if xargs didn't have that option, you could do something like:

    find -print0 | xargs -0 -l sh -c 'mv "$0" "$0".bak'
    But that's just getting silly, and even further from the point. =D
    ------------ :Wq Not an editor command: Wq
      That's why I said it was an aside.. :)

      Makeshifts last the longest.