My situation is:
I have csv file, named LG.0.csv LG.1.csv ..., depending of the source, looking like this:
Date,Source,counter1,counter2, ...
02/10/2016 09:25:21,LG.1,4.0364,2.8196, ...
I have a various number of this file, I could only have the LG.1.csv and LG.3.csv. My goal is to make a plot to compare the value of the counter.
I wrote a bash script to list the files presents in the directory, then plot them together.
#
DATE=`date +%m-%d-%Y`
counterArray=(c1 c2 c3 c4)
numberOfLG=4
for (( i=0; i<${#counterArray[@]}; i++ ));
do
column=$((i+3))
gnuplot << EOF
reset
set terminal png large size 1920,1080
set output '$1/plot${counterArray[$i]}.png'
set datafile separator ","
set timefmt '%m/%d/%Y %H:%M:%S'
set xdata time
set format x "%m/%d/%Y\n%H:%M:%S"
set title '${counterArray[$i]}'
set ylabel 'Mbps'
set yrange [0:*]
plot for [i=0:$numberOfLG] '/home/$USER/Results/$DATE/LG.'.i.'.csv' u 1:$column w lp t 'LG.'.i
EOF
done
As you can see I use a for loop to run the plot for each counter (save in an array).
This code works fine but does not allow a various number of file.
Now I want to use this to get the file name from the directory.
fileArray=($(find /home/$USER/Results/$DATE/remote/* -printf "%f\n"))
Then I found many many different way to do it but no one seems working so I get this.
plot for [file in ${fileArray[@]}] '/home/$USER/Results/$DATE/'.${file} u 1:$column w lp t ${file%.*}
How far am I do it? I get this error line 0: undefined variable: LG (corresponding to the ${fileArray[@]} )