Hello all,
I wish to introduce a for loop in my shell script and I was hoping I could get some help with this.
I am executing a command from a text file. I wish to execute each command 10 times and insert some stats into a csv file. After that command has been done, I want to start the next BUT put a line break in the CSV file after the first command that was done 10 times.
Is the following correct:
#Function processLine
processLine(){
line="$@"
for i in 1 2 3 4 5 6 7 8 9 10
do
START=$(date +%s.%N)
echo "$line"
eval $line > /dev/null 2>&1
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo "$line, $START, $END, $DIFF" >> file.csv 2>&1
echo "It took $DIFF seconds"
echo $line
done
}
Thanks all for any help
UPDATE
It is doing the loop correctly, but I can't get it to add a line break after each command is executed 10 times.