注意此时要将变量加上“”,不然当变量为空时,会出现[: =: unexpected operator
转载
2013-04-15 21:18:00
537阅读
2评论
我在ubuntu虚拟机下练习《鸟哥的Linux私房菜》中的shell脚本例子时,我习惯用vim编写完直接用sh xxx.sh来运行,并且还可以用sh -n xxx.sh 或者-x,-v等参数来调试脚本。当运行if then语句的例子时,突然报错:xxx unexpected operator,我暂且没有管它,因为我认为代码没有问题,并且我把if then的语句理解了就达到了学习的目的。但是在练习用
转载
精选
2014-10-20 18:47:03
852阅读
vi dos.txt
:set fileformat=unix
:w
原创
2023-04-20 16:44:37
129阅读
有时候,原来运行得好好的 shell 程序,换个平台就运行不了,例如下面 shell 程序。#!/bin/shif [ $1 == "hello" ]; then echo "Well done!"fi在 Ubuntu 上运
原创
2022-08-01 10:58:36
1121阅读
MySQL Shell 使用报错 SyntaxError: Unexpected identifier
原创
2023-04-21 16:17:41
618阅读
1. 错误 #!/bin/bashplatform=$1if[ "$platform" = "ibmaix64" ]then echo "$platform"else echo "hello ooo"fi Error : syntax
转载
2022-04-13 15:06:08
981阅读
解决方法:写完代码后不要直接“回车”,在每行尾部加“空格”再“回车”,保存文本。如果觉得空格碍眼,可以在保存运行后再删除空格。 同类其他的常见问题(如^M或win下编辑lin下不能用),网上搜索一大把,就不列举了。
转载
2021-04-18 21:45:13
1976阅读
2评论
debug shell:执行 sh -x test.sh vi test.sh :set fileformat=unix :wq解决问题原因是我在windows pycharm 写的格式不符合unix导致语法错误
原创
2022-09-20 11:37:07
216阅读
1. 错误 #!/bin/bashplatform=$1if[ "$platform" = "ibmaix64" ]then echo "$platform"else echo "hello ooo"fi Error : syntax error near unexpected token `then'原因: 条件语句 [ 符...
原创
2021-07-12 15:33:30
565阅读
很久没有用bash的shell来编写shell复杂脚本了,今天在combo-ew的项目中,在各项测试基本上都通过之后,试图编写一个脚本,用来将tftp服务器上的驱动、应用程序和配置文件下载到combo中,并完成相应驱动卸载重新安装和配置文件的检测等。在terminal中运行bash -n install_combo.bsh时,总是跳出这样一个错误:install_combo.bsh: line 28: syntax error: unexpected end of file。一开始因为文件有130多行,为了聚焦问题产生的地方,只保留第一个if控制,其他的全都屏蔽掉。但是问题依然存在:dingq
转载
2012-05-17 18:46:00
228阅读
2评论
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法google搜索,发现一位仁兄讲的挺好,内容如下: 用命令vi -b 打开你的SHELL脚本文件,你会。发现每行脚本最后多了个^M。 那么接下来就要搞清楚这个^M是什么东东? long
原创
2021-07-12 15:33:33
323阅读
1. 错误
#!/bin/bashplatform=$1if[ "$platform" = "ibmaix64" ]then echo "$platform"
else
echo "hello ooo"
fi
Error : syntax error near unexpected token `then'
原因: 条件语句 [ 符号的两边都要留空格
转载
2021-07-13 15:30:02
503阅读
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法google搜索,发现一位仁兄讲的挺好,内容如下: 用命令vi -b 打开你的SHELL脚本文件,你会。发现每行脚本最后多了个^M。 那么接下来就要搞清楚这个^M是什么东东? long
转载
2021-07-14 11:31:25
1105阅读
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法googl
转载
2022-04-18 15:43:35
657阅读
今天写了个较长的 脚本,结构嵌套比较多,最后运行时,出现了 的错误。 这个之前碰到过,经常在 系统转移脚本文件到 系统时出现,但这次我是在 环境中写的,不存在这个问题,改了试也没用。关于系统文件格式转化: 在网上查了一圈,全部都是文件格式错误的答案!程序人生CSDN中的答案真是烂透了,抄来抄去解决不
原创
2022-06-10 22:54:55
2857阅读
点赞
在Linux下运行shell脚本,报错syntax error: unexpected end of file使用vim打开脚本,执行命令::set fileformat=unix保存退出就可以了。问题解决。 原因是Linux下的文件结束符和Windows下的文件结束符不一样。在Windows上编辑的脚本,放在Linux系统上运行就会有这种问题。
原创
2022-07-12 13:15:40
828阅读
其实这是一个shell下判断符号 [ ] 加空格的问题,一定要小心编写《鸟哥》给的示例程序时,运行时出现:syntax error near unexpected token `then'[root@localhost scripts]# vi sh06-02.sh [root@localhost ...
原创
2021-08-13 14:15:44
1231阅读
执行脚本sh install.sh出现install.sh: 8: install.sh: Syntax error: "(" unexpected解决办法:
原创
2022-06-13 17:42:14
613阅读
In the world of open-source operating systems, Linux has consistently been a popular choice for many users due to its flexibility and security features. One of the most prominent distributions of Linu
原创
2024-05-07 11:09:58
16阅读
1、错误描述F:\dojo\abcd\abcc\views\login\login.pug:3:1 1| doctype html 2| > 3| h1= title -------^ 4| p Welcome ...
转载
2019-01-23 14:40:00
321阅读
2评论