BASH Syntax error near unexpected token 'done'

前端 未结 12 857
轮回少年
轮回少年 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:16

    Sometimes this error happens because of unexpected CR characters in file, usually because the file was generated on a Windows system which uses CR line endings. You can fix this by running os2unix or tr, for example:

    tr -d '\015' < yourscript.sh > newscript.sh

    This removes any CR characters from the file.

提交回复
热议问题