bo_pnw
Last Updated: February 25, 2016
·
750
· cornwe19

Android Device ID Utility

A commandline utility to get the device ID of the nth device plugged in. This is useful if you often run adb commands with multiple devices plugged in. Drop this in your ~/.profile:

# Usage: 'device 1' returns the first device plugged in
function device()
{
    devIndex=`expr "$1" + 1`
    adb devices | head -$devIndex | tail -n 1 | awk '{print $1}'
}