如何在 ADB shell 中使用 if 比较 2 个字符串
如何在 ADB shell 中使用 if 比较 2 个字符串, 我正在尝试使用 :
if ["a" = "a"];
then
fi
这给出了一个错误 [: not find
我尝试了 if 的所有变体,得到了相同的错误,
甚至只是
if [];
then
fi
给出了相同的答案。
How to use if in comparing 2 strings in ADB shell,
I am trying to use :
if ["a" = "a"];
then
fi
this gives an error [: not found
I tried all the varients of if , got the same error,
even just
if [];
then
fi
is also giving the same answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果在括号内添加空格会怎么样,如下所示:
What if you put spaces inside the brackets, like this:
根据 http://developer.android.com/guide/developing/tools/adb .html,adb(Android 调试桥)使用
ash
shell。我没有
adb
,但我的 Ubuntu 系统上有ash
。在该系统上,可以执行以下操作:在 adb shell 中尝试精确代码,包括所有间距。特别是
[
周围和]
之前的空格是强制性的。请注意,
]
后面的分号不是必需的;可能没问题,但为了确定起见,请删除它。 (你说你“尝试了所有类似的东西”。不要尝试“类似的东西”;试试这个。)你确定你在 shell (
adb shell
) 中而不是在adb
本身? (我不知道adb
是否有交互模式,所以这可能没有意义。)According to http://developer.android.com/guide/developing/tools/adb.html, adb (Android Debug Bridge) uses the
ash
shell.I don't have
adb
, but I do haveash
on my Ubuntu system. On that system, the following works:Try that exact code in your adb shell, including all the spacing. In particular the spaces around the
[
and preceding the]
are mandatory.Note that the semicolon after the
]
is not required; it's probably ok, but delete it just to be sure. (You said you "tried all the similar stuff". Don't try "similar stuff"; try this.)Are you sure you're in the shell (
adb shell
) and not inadb
itself? (I don't know whetheradb
has an interactive mode, so that might not make sense.)