在bash中声明数组时出现错误“语法错误:”(“”意外) [英] Error 'Syntax error: "(" unexpected' when declaring arrays in bash
本文介绍了在bash中声明数组时出现错误“语法错误:”(“”意外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
与此OP 相同的问题 ,但必须是单独的原因。
Same problem as this OP, but must be a seperate cause.
以下脚本:
#!/bin/sh
arr=("cat" "dog" "bird")
可交互工作(debian),但在crontab调用时失败,
Works interactively (debian) but fails when called by crontab with:
/bin/sh: 2: /path/zero_check.sh: Syntax error: "(" unexpected
我尝试使用#!/ bin / bash
shebang,并用 declare -a arr =( cat狗狗 bird)
声明数组,
I've tried with #!/bin/bash
shebang, and declaring array with declare -a arr=("cat" "dog" "bird")
, to no effect.
知道为什么吗?
推荐答案
指定您的
bash /path/zero_check.sh
而不是
/path/zero_check.sh
这篇关于在bash中声明数组时出现错误“语法错误:”(“”意外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文