Skip to content

Instantly share code, notes, and snippets.

@NotWoods
Created September 3, 2019 21:55
Show Gist options
  • Save NotWoods/65939d554888420594cd344a1ec02b35 to your computer and use it in GitHub Desktop.
Save NotWoods/65939d554888420594cd344a1ec02b35 to your computer and use it in GitHub Desktop.
Run ADB command on all connected devices
# Use `source adb-all.sh` to get the adb-all command in the shell
# Run adb command on all connected devices
function adb-all() {
# adb devices -l: Print all devices, along with connected ports. Works with devices missing a serial no.
# egrep '(device|emulator) usb': Select lines with devices listed. (ex: SERIAL device usb:2-1.4.6)
# awk '{print $3}': Select the third item in the line, seperated by whitespace
# xargs ...: Run adb for each line piped in
adb devices -l | egrep '(device|emulator) usb' | awk '{print $3}' | xargs -t -I% -n1 -P5 \
adb -s % "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment