DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Perl Script To Apply A Ruby File To All Xml Files

10.30.2008
| 3844 views |
  • submit to reddit
        Perl script to apply a ruby file to all xml files and to prepend its output with the filename.

ls *xml | perl -ne 'chomp($f = $_);@l = readpipe("cat $f|~/src/aangifte_naar_csv.rb"); print map { "$f,$_" } (@l)' > pl_uitvoer.csv
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 3:04pm

You could also use xargs, if the Ruby script can be called per line.

Snippets Manager replied on Sat, 2008/10/18 - 9:28am

Hehe :) I know, it is insane, but I needed a really quick'n'dirty method

Snippets Manager replied on Thu, 2008/10/30 - 5:44pm

Please please please don't do that. Just make your Ruby script take arguments and do it all inline... this is just insane.