How to use if in comparing 开发者_JAVA技巧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.
What if you put spaces inside the brackets, like this:
if [ "a" = "a" ]
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 have ash on my Ubuntu system. On that system, the following works:
if [ "a" = "a" ]
then
echo ok
fi
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 in adb itself? (I don't know whether adb has an interactive mode, so that might not make sense.)
加载中,请稍侯......
精彩评论