Shell脚本错误期望“执行" [英] shell script error expecting "do"

查看:89
本文介绍了Shell脚本错误期望“执行"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#!/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 :
do
echo "WTF"
done

推荐答案

我怀疑行尾.

尝试:

hexdump -C yourscript.sh 

并查找0d 0a序列.您可以使用tr命令剥离\r(0d):

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

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

这篇关于Shell脚本错误期望“执行"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆