Running adb commands on all connected devices

adb, android

Solution

Create a bash file and name it e.g. `adb+`:

#!/bin/bash
adb devices | while read -r line
do
if [ ! "$line" = "" ] && [ "$(echo "$line" | awk '{print $2}')" = "device" ]
then
    device=$(echo "$line" | awk '{print $1}')
    echo "$device" "$@" ...
    adb -s "$device" "$@"
fi
done

Usage: `./adb+ <command>`

Problem

Is there a way of running adb commands on all connected devices? To uninstall an app from all connected devices with "adb uninstall com.example.android". The commands I am interested in is mainly install and uninstall. I was thinking about writing a bash script for this, but I feel like someone should have done it already :)

Original source

Related problems