Any idea of what the problem could be?
My code is:
#!/bin/bash
while :
do
echo \"Press [CTRL+C] to stop..\"
sleep 1
done
Saved it a
Run cat -v file.sh.
You most likely have a carriage return or no-break space in your file. cat -v will show them as ^M and M-BM- or M- respectively. It will similarly show any other strange characters you might have gotten into your file.
Remove the Windows line breaks with
tr -d '\r' < file.sh > fixedfile.sh