I would like to plot multiple curve on the same graph using a for loop. Each data file (named stat_coupe) is located in a different folder (fwal055wal055/rep16/ and fwal055wal055_c2/rep20/). fwal055wal055 and fwal055wal055_c2 correspond to names of simulation. First, I need to get a previous result, a single number (Utau), in other files (named file_fwal055wal055 and file_fwal055wal055_c2). This is successfully done thanks to the command awk. The result depend on the file: Utaufwal055wal055=10.5 and Utaufwal055wal055_c2=12.2.
Then I need to divid the 1st column of the file stat_coupe corresponding to the path fwal055wal055/rep16/ by the value of Utaufwal055wal055 and do the same thing for the file stat_coupe corresponding to the path fwal055wal055_c2/rep20/ with the value of Utaufwal055wal055_c2. Moreover, each plot should have a specific format which depend on the type of simulation run (fwal055wal055 or fwal055wal055_c2).
The presented problem is reduced to 2 simulations fwal055wal055 and fwal055wal055_c2 and 1 plot but I have about 20 simulations and 15 various graphs to plot that is why I would like to use the for loop.
To summary at each iteration I have:
- a specific format,
- a specific path,
- a specific value of Utau
I want to indicate the wright format, path and value of Utau at each iteration of the for loop. The solution I propose below successfully permits to obtain the value of Utau for each simulation but the code @path_.i and @format_.i does not work.
#!/bin/bash
for elem in fwal055wal055 fwal055wal055_c2;
do
Utau[${elem}]=$(awk 'FNR==5{print $1}' file_$elem)
done
gnuplot -persist <<-EOFMarker
format_fwal055wal055='pt 1 ps 1.0 lc 0 title "WALE"'
format_fwal055wal055_c2='pt 2 ps 1.0 lc 0 title "WALE c2"'
path_fwal055wal055='"fwal055wal055/rep16/stat_coupe"'
path_fwal055wal055_c2='"fwal055wal055_c2/rep20/stat_coupe"'
list="fwal055wal055 fwal055wal055_c2"
plot for [i in list] @path_.i u 1:(\$2/${Utau[${i}]}) @format_.i
EOFMarker
I would like to obtain something equivalent to:
plot @path_fwal055wal055 u 1:(\$2/${Utau[${i}]}) @format_fwal055wal055,\
@path_fwal055wal055_c2 u 1:(\$2/${Utau[${i}]}) @format_fwal055wal055_c2
Can someone help me to solve this issue ?
Thank you very much, Martin
awk, so my guess would be that you have a list of files in the same directory and want to extract from each of them the value of the 5th row of the 1st column and with these values normalize the 2nd column of other related files which are in different directories. Please correct me if I'm wrong. This could also be achieved without usingawk. - theozhawkis a bash command to get the value of Utau. Could you explain me how to get the value of Utau without usingawkknowing that the values of Utau (Utaufwal055wal055 and Utaufwal055wal055_c2) are localised in separated files (file_fwal055wal055 and file_fwal055wal055_c2) which are different from the plot files "stat_coupe" ? I thought to :stats "file_fwal055wal055" every ::5::5 u $1 nooutputBut I do not see how to put it inside the for loop in order to specify the iteration fwal055wal055 or fwal055wal055_c2. - Martin7