Created
April 9, 2014 19:42
-
-
Save dallasgutauckis/10306968 to your computer and use it in GitHub Desktop.
Lists connected Android devices (via adb) and the device's corresponding model and OS version - See http://dallasgutauckis.com/2014/04/09/listing-connected-android-devices-with-os-version-and-model/
This file contains 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
#!/bin/bash | |
if [[ ! $PATH_TO_ADB ]]; then | |
PATH_TO_ADB=`which adb` | |
fi | |
if [[ ! $PATH_TO_ADB ]]; then | |
if [[ ! $ANDROID_HOME ]]; then | |
echo "Failed to determine path to adb; consider setting ANDROID_HOME to your SDK directory or PATH_TO_ADB to the path to ADB" | |
exit 1 | |
fi | |
PATH_TO_ADB="$ANDROID_HOME/platform-tools/adb" | |
fi | |
devices=`$PATH_TO_ADB devices | grep -E "device\$" | cut -f1` | |
for device in $devices; do | |
model=$($PATH_TO_ADB -s $device shell getprop ro.product.model | tr -d '\r') | |
version=$($PATH_TO_ADB -s $device shell getprop ro.build.version.release | tr -d '\r') | |
printf '%-20s [%6s]: %-20s \n' "$device" "$version" "$model" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's sometimes convenient to have both version name and version code (aka API lvl).