Skip to content

Instantly share code, notes, and snippets.

@schlan
Last active December 5, 2016 15:44
Show Gist options
  • Save schlan/559419576e634ba74d33 to your computer and use it in GitHub Desktop.
Save schlan/559419576e634ba74d33 to your computer and use it in GitHub Desktop.
Send adb commands to all connected devices
#!/bin/bash
if [ "$#" -lt 1 ]
then
echo "No arguments given"
exit
fi
ADB="adb"
ARGS="$@"
echo
$ADB devices -l | sed '1d;$d' | while read device
do
PRODUCT=`sed "s/^.*\(product\:[^\\ ]*\).*$/\1/g" <<< $device | cut -d ':' -f2`
MODEL=`sed "s/^.*\(model\:[^\\ ]*\).*$/\1/g" <<< $device | cut -d ':' -f2`
echo "==== " $PRODUCT / $MODEL " ===="
ID=`cut -d ' ' -f1 <<< $device`
$ADB -s $ID $ARGS
echo
done
@schlan
Copy link
Author

schlan commented Jan 7, 2016

#> adb-all shell getprop ro.build.version.sdk

====  sdk_google_phone_x86 / Android_SDK_built_for_x86  ====
22

====  angler / Nexus_6P  ====
23
#> adb-all get-state

====  sdk_google_phone_x86 / Android_SDK_built_for_x86  ====
device

====  angler / Nexus_6P  ====
device

#> adb-all shell am start -a android.intent.action.VIEW -d http://www.google.com

====  sdk_google_phone_x86 / Android_SDK_built_for_x86  ====
Starting: Intent { act=android.intent.action.VIEW dat=http://www.google.com }

====  angler / Nexus_6P  ====
Starting: Intent { act=android.intent.action.VIEW dat=http://www.google.com/... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment