Skip to content

Instantly share code, notes, and snippets.

@bryanmylee
Created May 15, 2025 03:00
Show Gist options
  • Save bryanmylee/1f54e3fc4b6eadbd9e0b424f8bcb65a8 to your computer and use it in GitHub Desktop.
Save bryanmylee/1f54e3fc4b6eadbd9e0b424f8bcb65a8 to your computer and use it in GitHub Desktop.
Get the device ID for a given AVD name
#!/bin/bash
TARGET_AVD_NAME=$1
for id in $(adb devices | grep emulator | cut -f1); do
name=$(adb -s $id emu avd name | head -1 | tr -d '\r')
if [ "$name" = "$TARGET_AVD_NAME" ]; then
echo "$id"
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment