Executing commands

I need to execute a command to run my script several times with varying parameters

perl ex.pl -b 130198 -e 130884 -c plot  plot.txt 1_plot.txt
perl ex.pl -b 1345 -e 1308 -c plot  plot.txt 2_plot.txt
perl ex.pl -b 1345567 -e 130898 -c plot  plot.txt 3_plot.txt
.
.
.
100's of excutions

The varying parameters are -b -e and the output file (1_plot.txt, 2_plot.txt..)

I have the varying parameters in a file (as separate or together). Please let me know the best way to execute this several times.

LA

---------- Post updated at 12:48 PM ---------- Previous update was at 11:33 AM ----------

Is there a way to do it in awk or sed

For example if the values are two per line in the input file, you could try something like this:

i=0
while read begin end
do
  perl ex.pl -b "$begin" -e "$end" -c plot  plot.txt $((++i))_plot.txt
done < infile
1 Like

Scrutinizer's solution should be the best.

by awk

awk '{printf "perl ex.pl -b %s -e %s -c plot  plot.txt %d_plot.txt \n",$1,$2,++i}' infile |sh