adb uninstall 命令在 Bash shell for 语句中不起作用
由于工作原因,我需要卸载并重新安装 Android 设备中的多个应用程序。为了快速完成此操作,我可以轻松编写脚本来执行此操作,这样我就不需要一次又一次地键入它。这是我的脚本:
#!/bin/sh
#adb uninstall com.company.myapp
for i in `adb shell pm list packages|grep company|awk -F':' '{ print $2 }'`; do
echo adb uninstall "$i"
adb uninstall "$i"
done
奇怪的是“adb”总是打印“失败”,而“echo”打印正确的命令。 如果取消注释,第二行将正常工作。
任何人都可以帮忙找出问题所在吗?
For work reason, I need to uninstall and reinstall several apps in Android device. To do it quickly, it's easy for me to write a script to do this so that I don't need to type it again and again. Here is my script:
#!/bin/sh
#adb uninstall com.company.myapp
for i in `adb shell pm list packages|grep company|awk -F':' '{ print $2 }'`; do
echo adb uninstall "$i"
adb uninstall "$i"
done
The odd thing is `adb' always prints "Failure" while 'echo' prints the right command.
The second line will work fine if uncomment it.
Anyone can help to figure out what the problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“失败”...我使用 dos2unix 来解决同样的问题,但像 tr -d "\r" 更好。
并非每个 adb shell 命令都会附加 MSDOS CRLF,但只是某些时候而已。
adb 卸载失败
'Failed' ... i used dos2unix to get around this same issue, but like tr -d "\r" better.
Not every adb shell command appends the MSDOS CRLF, but only some some of the time.
adb uninstall failed
是必需的 dos2unix 命令,在下一个示例中我将展示实现:
Is necessary dos2unix command, in the next example I'll show implementation: