Bash break and continue
break stops a loop at once. continue skips the rest of the current round and goes on with the next one.
Both work in for, while and until loops.
Skip one number, stop at another
Save this as numbers.sh:
#!/bin/bash
for i in 1 2 3 4 5; do
if [ $i -eq 2 ]; then
continue
fi
if [ $i -eq 4 ]; then
break
fi
echo "Number $i"
done
Run it:
./numbers.sh
Number 1
Number 3