What is the difference between using a colon, which means "do nothing" and continue, which means skip.
if [[ -s $file ]] ; then
:
fi
if [[ -s $file ]] ; then
continue
fi
: is a synonym for true. It does not prevent later commands in the same block or loop from running.
Compare:
for (( i=0; i<3; i++ )); do
echo "Starting iteration $i"
(( i == 1 )) && { echo " About to run :"; :; echo " Just ran :"; }
(( i == 2 )) && { echo " About to run continue"; continue; echo " Just ran continue"; }
echo "Ending iteration $i"
done
Our output is:
Starting iteration 0
Ending iteration 0
Starting iteration 1
About to run :
Just ran :
Ending iteration 1
Starting iteration 2
About to run continue
Note that we made it to "ending" after running :, but not after running continue.
It depends on your program's logic.
Outside of a loop you get
$ continue
bash: continue: only meaningful in a `for', `while', or `until' loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With