linux - Extract arguments from stdout and pipe -


i trying execute script n times different file argument each time using this:

ls /user/local/*.log | xargs script.pl 

(script.pl accepts file name argument)

but script executed once. how resolve ? not doing correctly ?

 ls /user/local/*.log | xargs -rn1 script.pl 

i guess script expects 1 parameter, need tell xargs that.

passing -r helps if input list empty

note following is, in general, better:

 find /user/local/ -maxdepth 1 -type f -name '*.log' -print0 |        xargs -0rn1 script.pl 

it handle quoting , directories safer.


to see xargs executes use -t flag.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -