I am pretty new to bash, and I come across this code.
j=0
while ! nc -z "$host" "$port"; do
j=$((j+1))
if [ $j -ge 10 ]; then
echo >&2 "$host:$port not reachable, giving up"
exit 1
fi
done
I cannot understand how the !
before the nc
work here. Can anyone help explain that?
Thanks