BASH Syntax error near unexpected token 'done'

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

    Might help someone else : I encountered the same kind of issues while I had done some "copy-paste" from a side Microsoft Word document, where I took notes, to my shell script(s).

    Re-writing, manually, the exact same code in the script just solved this.

    It was quite un-understandable at first, I think Word's hidden characters and/or formatting were the issue. Obvious but not see-able ... I lost about one hour on this (I'm no shell expert, as you might guess ...)

提交回复
热议问题