Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: File::Find considered hard?

by Aristotle (Chancellor)
on Mar 15, 2004 at 07:18 UTC ( [id://336621]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://336621]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found