如何创建以下 Android bash 脚本?

发布于 2024-12-22 18:44:12 字数 320 浏览 3 评论 0原文

当我输入:

adb devices

我的输出是(这可以是变量,它可以列出 10 或 20 等):

List of devices attached 
0280414640c133d7    device
TA054085R1  device

之后我想运行:

adb install MyApp 0280414640c133d7
adb install MyApp TA054085R1

如何在 bash 脚本中实现这一点?

When I type:

adb devices

My output is (this can be variable, it can list 10 or 20 etc):

List of devices attached 
0280414640c133d7    device
TA054085R1  device

Afterwards I'd like to run:

adb install MyApp 0280414640c133d7
adb install MyApp TA054085R1

How can I get this going in a bash script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜宝宝 2024-12-29 18:44:12

我不确定您需要您的解决方案有多强大,但是类似的事情将适用于您上面描述的情况:

   #!/bin/bash

echo "Deploying SONR to devices..."

#install SONR
for foo in `adb devices | egrep 'device

毫无疑问,可以替换通过 cut 管道传输的丑陋 egrep 只需调用 sedawk 甚至 perl 单行代码即可。

| cut -d ' ' -f1` do adb -s $foo install SONR.apk done

毫无疑问,可以替换通过 cut 管道传输的丑陋 egrep 只需调用 sedawk 甚至 perl 单行代码即可。

I'm not sure how robust you need your solution to be, but something like this will work with the case you describe above:

   #!/bin/bash

echo "Deploying SONR to devices..."

#install SONR
for foo in `adb devices | egrep 'device

It is no doubt possible to replace the ugly egrep piped through cut with a single call to sed or awk or even a perl one-liner.

| cut -d ' ' -f1` do adb -s $foo install SONR.apk done

It is no doubt possible to replace the ugly egrep piped through cut with a single call to sed or awk or even a perl one-liner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文