test.sh: line 12: syntax error in conditional expression test.sh: line 13: syntax error near `then' test.sh: line 13: `then' 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 仔细查看是由于 if 条件中的中括号[ ]与变量之间...
【shell 】syntax error in conditional expression 简介:编写shell 脚本时遇见 syntax error in conditional expression 错误,#!/bin/bash# cleanup /var/log/messageLOG_DIR=/var/logROOT_DID=0LINES=50E_XC... 编写shell 脚本时遇见 syntax error in conditional expression 错误, #!/bin/bash # cleanup /var...
6firoot@cenos62-64 [10:33:25] [~/vm8500_Uniview] -># sh test01.shtest01.sh: line 2: syntax errorinconditional expression test01.sh: line 2: syntax error near `"133"' test01.sh: line 2: `if [[ "133" <= "133" ]];then'root@cenos62-64 [10:33:30] [~/vm8500_Uniview] ...
[[ 2 < 3 && 4 > 5 ]] &&echo'ok'ok [[ 2 < 3 -a 3 > 4 ]] &&echo"ok"-bash: syntax errorinconditional expression -bash: syntax error near `-a' 注意:[[]] 运算符只是[]运算符的扩充。能够支持<,>符号运算不需要转义符,它还是以字符串比较大小。里面支持逻辑运算符:|| && ,不再使...
bash: syntax error in conditional expression<> bash: syntax error near `-a'<> $ [ 1 < 2 -a b > a ]&&echo true||echo false<> true<> $ [ 1 < 2 && b > a ]&&echo true||echo false #wrong syntax<> bash: [: missing `]'<> ...
tes.sh: line 2: syntax error in conditional expression tes.sh: line 2: syntax error near `-o' tes.sh: line 2: `if [[1−eq0−o2 -eq 1 ]];then' 以下写法才正确 [root@fsf /server/script]# vim tes.sh !/bin/bash if [1−eq0−o2 -eq 1 ];then ...
# [[ 1 < 2 && b > a ]] && echo true || echo false true # [[ 1 < 2 -a b > a ]] && echo true || echo false bash: syntax error in conditional expression bash: syntax error near `-a’ # [ 1 < 2 -a b > a ] && echo true || echo false true # [ 1 < 2 && ...
[root@zabbix01 script]# [[ 18 >= 16 ]] && echo 1 || echo 2 -bash: syntax error in conditional expression -bash: syntax error near `16' [root@zabbix01 script]# [[ 18 \>= 16 ]] && echo 1 || echo 2 -bash: conditional binary operator expected -bash: syntax error near `\>=...
原因是脚本中正则里的符号问题,在if中不好处理。最好是先把这个正则定义成一个变量,然后在if中引用,如下 regex_line="^java\.library\.path=(.*)$"...if [[ $line =~ "$regex_line" ]]; then...
The conditional ends with esac. 脚本将$1与用字符)分隔的每个case值进行匹配。 如果一个case值与$1匹配,shell将执行case下面的命令,直到遇到;;,然后跳转到esac关键字。 条件以esac结束。 For each case value, you can match a single string (like bye in the preceding example) or multiple strings with...