简体   繁体   中英

How can I create the following Android bash script?

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?

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$' | 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM