Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: multiple file operations using perl one-liners

by ikegami (Pope)
on May 17, 2009 at 19:47 UTC ( #764547=note: print w/ replies, xml ) Need Help??


in reply to Re: multiple file operations using perl one-liners
in thread multiple file operations using perl one-liners

-n + chomp can be replaced with -nl.

That should be /\t/, I think? -a would be better than split

du -b */*/old.zip | perl -F\\t -lane'system zip => "-d", $F[1], "*exe* +"'

Or shorter and simpler yet:

du -b */*/old.zip | perl -ne'system zip => "-d", /\t(.*)/, "*exe*"'

My earlier comment on error checking still applies.


Comment on Re^2: multiple file operations using perl one-liners
Select or Download Code
Replies are listed 'Best First'.
Re^3: multiple file operations using perl one-liners
by sflitman (Hermit) on May 17, 2009 at 22:03 UTC
    That last one totally rocks, Ikegami!

    I always learn something when I post here.

    SSF

Re^3: multiple file operations using perl one-liners
by morgon (Deacon) on May 17, 2009 at 22:36 UTC
    -n + chomp can be replaced with -nl
    Thanks - quite useful to know.

    Gotta re-read the perlrun-manpage.

Re^3: multiple file operations using perl one-liners
by jwkrahn (Monsignor) on May 18, 2009 at 01:51 UTC

    Or:

    perl -e'system zip => -d => /\t(.*)/, "*exe*" for `du -b */*/old.zip`'

      Is there any advantage to this variant? It's longer and buggy (missing chomp). It's also less clear due the weird use of => to separate two of three arguments, especially when it's also used to associate the arguments to the command.

      Either way, I just realised du is useless.

      perl -e'system zip => "-d", $_, "*exe*" for @ARGV' */*/old.zip

        TMTOWTDI    ;-)

        perl -e'system "zip", "-d", $_, "*exe*" for <*/*/old.zip>'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (17)
As of 2015-07-30 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls