在编写shell程序时,我们经常使用/bin/sh和/bin/bash.我经常使用bash,但我不知道它们之间有什么区别.
bash和之间的主要区别是sh什么?
我们究竟需要意识到在编程时bash和sh?
我遇到了代码所在的shell脚本
for line in $LIST_ARRAY;do
if [[ $LIST_ARRAY =~ $line ]]
then
echo "true"
....
...
.
Run Code Online (Sandbox Code Playgroud)
什么是使用=~在这种情况下?
在我的bash脚本,我检查的第一个参数是要么-,0或者+使用下面if的语句:
LEVEL=$1
if [ "$LEVEL" -ne "-" ] && [ "$LEVEL" -ne "0" ] && [ "$LEVEL" -ne "+" ]
then
echo "The value of LEVEL must be either -, 0, or +!"
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
但它给了我错误[: -: integer expression expected,指的是if声明条件的行.
我一直在尝试许多不同的语法(例如,双重与单一括号,引用与非引用变量和字符串文字),但我无法弄明白.