Kayan Kayan - 11 months ago 54
Bash Question

gnuplot with muliple files using loop

I have a number of files with following order:

file_001.txt, file_002.txt, file_003_txt,
file_021.txt, file_023.txt, file_023.txt,
file_041.txt, file_042.txt, file_043.txt,
file_061.txt, file_062.txt, file_063.txt,
file_081.txt, file_082.txt, file_083.txt,
file_101.txt, file_102.txt, file_103.txt

I would like to plot each file in gnuplot using a loop. I can not able to make a loop. However my following script is working and looks a long script.

for [i=1:3] 'file_00'$i'.txt' u 1:2,\
for [i=1:3] 'file_02'$i'.txt' u 1:2,\
for [i=1:3] 'file_04'$i'.txt' u 1:2,\
for [i=1:3] 'file_06'$i'.txt' u 1:2,\
and so on

How can I make the loop in any other efficient ways?


You can use embedded loop:

plot for [j=0:10:2] for [i=1:3] 'file0'.j.i.'.dat' u 1:2;

#for [<var> = <start> : <end> {: <incr>}]