将ADB输出传递到bash脚本中的变量
我试图创建BASH脚本以用ADB Shell手动安装拆分APK 需要使用命令bellow
命令
session ='pm install -install -streate -s 42211368'
来获取会话ID 。
的会话ID
547376362将是我想将547376362传递到会话变量
sh< 。 pm install install -write -s 24628703 $ {session} 0
/sdcard/ytapkm/base.apk 因此,结果应为“ sh< pm install -write -s install -s install -s 24628703 547376362 /YTAPKM/base.apk“
im trying to create bash script to install split APKs manually with adb shell
that requires to get session id using the command bellow
command
SESSION='pm install-create -S 42211368'
this will output something like : Success: created install session [547376362]
547376362 will be the session ID
I want to pass 547376362 into SESSION Variable
sh < pm install-write -S 24628703 ${SESSION} 0 /sdcard/YTAPKM/base.apk
so result shall be "sh < pm install-write -S 24628703 547376362 0 /sdcard/YTAPKM/base.apk"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GREP
就足够了。要解释发生的事情:
grep -e
使用“扩展”正则表达式(易于使用)grep -o
仅输出匹配部分,在这种情况下的整数session = $(some_cmd)
将stdout从some_cmd
存储到变量session
,并允许使用管道等等grep
is sufficient for this.To explain what's happening a bit:
grep -E
uses "extended" regular expressions (easier to work with)grep -o
outputs only the matching part, the integer in this caseSESSION=$(some_cmd)
stores the stdout fromsome_cmd
to the variableSESSION
, and allows for pipes and such too