Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: multiple file operations using perl one-liners

by morgon (Priest)
on May 17, 2009 at 19:43 UTC ( #764545=note: print w/replies, xml ) Need Help??

in reply to multiple file operations using perl one-liners

Am I missing something or is this far too complicated?

Why are you sorting your files when you want to process all of them anyway?

And I can't see a real reason for your "xcol" or an intermediate file, you can do all of it one go like this (-n does the looping here):

du -b */*/ | perl -ne 'chomp; my $f = (split /t/)[1]; system qq +{zip -d $f "*exe*"}'

Replies are listed 'Best First'.
Re^2: multiple file operations using perl one-liners
by ikegami (Patriarch) on May 17, 2009 at 19:47 UTC
    -n + chomp can be replaced with -nl.

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

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

    Or shorter and simpler yet:

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

    My earlier comment on error checking still applies.

      That last one totally rocks, Ikegami!

      I always learn something when I post here.


      -n + chomp can be replaced with -nl
      Thanks - quite useful to know.

      Gotta re-read the perlrun-manpage.


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

        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' */*/

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2022-01-19 20:56 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (56 votes). Check out past polls.