Skip to content

Instantly share code, notes, and snippets.

@jack-webb
Last active October 1, 2022 15:34
Show Gist options
  • Save jack-webb/dc7c93abd316705f4137b83c09eab082 to your computer and use it in GitHub Desktop.
Save jack-webb/dc7c93abd316705f4137b83c09eab082 to your computer and use it in GitHub Desktop.
Using ADB and xargs to interact with multiple devices
# Install an app and keep it's data, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X install -r {me.jackwebb.app}
# Grant a permission to your app, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb grant {me.jackwebb.app} {READ_CONTACTS}
# Run an intent, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb start {me.jackwebb.app} {my intent here}
# This command works by creating a list of connected devices, then
# using xargs to run your command against each device in the list.
#
# I've included some common use cases here, but any adb command
# (or any other command) can can be used, like this:
adb devices | tail -n +2 | cut -sf 1 | xargs -IX {your adb command here}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment