BASH Syntax error near unexpected token 'done'

前端 未结 12 891
轮回少年
轮回少年 2020-12-01 05:52

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

12条回答
  •  悲哀的现实
    2020-12-01 06:03

    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
    

提交回复
热议问题