command line - How do I run a perl script on multiple files and produce the same number of saved output files? -
i have simple perl script want run on folder full of .txt files.
i read answers how run perl script on multiple input files same extension? , did not understand how implement answers.
i have have googled etc. , not understand answers on perlmonks.
on mac os terminal using
perl myscript.pl input.txt > output.txt
but don't know how run on folder full of .txt files.
i'd content either producing new set of modified .txt files (one output per input) or editing files , overwriting input output if easier.
this more of command line/bash question perl question, understand want run following against multiple files
perl myscript.pl input.txt > output.txt
the easiest way execute following command terminal
find . -name "*.txt" -exec sh -c 'perl myscript.pl {} > {}.out' \;
this files match *.txt
, , execute command between --exec sh -c'
, '\;
, replacing {}
name of file.
Comments
Post a Comment