Last active
October 1, 2022 15:34
-
-
Save jack-webb/dc7c93abd316705f4137b83c09eab082 to your computer and use it in GitHub Desktop.
Using ADB and xargs to interact with multiple devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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