开发者

shell script error expecting "do"

开发者 https://www.devze.com 2023-02-21 01:36 出处:网络
#!/bin/sh while true ; do echo \"WTF\" done This is giving a syntax error: syntax error: unexpected end of file (expecting \"do\")
#!/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:

#!/bin/开发者_如何转开发sh
while :
do
echo "WTF"
done


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


Give this a try:

#!/bin/sh
while [ true ]
do
    echo "WTF"
done

Please pay special attention to the spaces in the line 'while [ true ]'

0

精彩评论

暂无评论...
验证码 换一张
取 消