BASH Syntax error near unexpected token 'done'

bash

Solution

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

Problem

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 as .sh and ran bash file.sh CentOS 6 32-bit What is the issue? First time EVER using BASH, need it for a simple infinite loop on something.

Original source

Related problems