在 linux bash shell 中,如何在 if
中从另一个变量中减去一个变量?我尝试了以下方法:
#!/bin/bash
start=0
end=1
if [ end - start -eq 1 ]; then
echo "right"
fi
它不起作用。
最佳答案
既然你特别提到了bash,那就用它的算术支持吧:
#!/bin/bash
start=0
end=1
if ((end - start == 1)); then
echo "right"
fi
关于linux - linux shell 中的减法 if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32545247/