Linux noob with Raspbian, I am writing my 1st bash scipt which there is a for loop.
In this loop there is an if condition, if the condition fails, I want to decrement the counter to start again with no impact on the final number of results (hope I am clear enough).
It seems I cannot modify the counter ("let" command doesn't work) and google was not a great help...
Code: Select all
for i in `seq 1 10` # exact number of increments TBD
do
# Creates directory to store csv files, its name is date/hour based
date=`date +%d-%m-%y_%H-%M-%S`
mkdir $data/$date
# Executes C program
sudo ./main
# Tests if csv files are present
if [ -e $prog/*.csv ]
then
# Moves csv files from C program directory to data base directory
sudo mv *.csv $data/$date
# Delay before next C program execution
sleep 1h # exact delay TBD
else
# If no csv files present, add a message and restart after a small delay
cp $data/.if_problem $data/$date/READ_ME.txt
sleep 1
let "i=i-1"
fi
done
Thank you
Flav