shell script error expecting “do”

后端 未结 2 1554
心在旅途
心在旅途 2021-01-31 10:37
#!/bin/sh
while true ; do
echo \"WTF\"
done

This is giving a syntax error: syntax error: unexpected end of file (expecting \"do\")

I also tried

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 10:58

    I suspect line endings.

    Try:

    hexdump -C yourscript.sh 
    

    And look for 0d 0a sequences. You can strip \r (0d) with the tr command:

    cat yourscript.sh | tr -d '\r' >> yournewscript.sh
    

提交回复
热议问题