Possible Duplicate:
shell script in android gives [: not found
我需要在 shell 脚本中编写一个条件语句。
我用过这个方法
#!/bin/sh
c=1
if [ $c == 1 ]
then
echo c is 1
else
echo c is 0
fi
这在 Linux 机器上工作正常,但 android shell 在 if [ $C == 1 ]
方面存在一些问题它给了我像
[: not found
那么 shell 脚本中是否还有其他条件语句,以便我可以以这种方式转换我的逻辑?
最佳答案
通常 [ 是 test 的别名,在 bash 中它是内置的。 输入 [
查看它是什么。
另一种选择是使用测试
#!/bin/sh
c=1
if test "$c" = 1
then
echo c is 1
else
echo c is 0
fi
=
用于字符串比较,-eq
用于数字比较
关于android - shell脚本中的if []还有其他选项吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12066311/