Skip to content

Instantly share code, notes, and snippets.

@manadream
Created March 21, 2015 16:30
Show Gist options
  • Save manadream/b3d4ee1710d956d34f00 to your computer and use it in GitHub Desktop.
Save manadream/b3d4ee1710d956d34f00 to your computer and use it in GitHub Desktop.
Bash Script for connecting to and parsing android devices over adb
getDevices () {
DEVICES=($(adb devices | grep "device$" | sed -e "s|device||g"))
for i in {1..9}
do
FOUND=0
for j in ${DEVICES[@]}
do
if [ "$j" == "192.168.56.10${i}:5555" ]
then
FOUND=1
fi
done
if [ ${FOUND} -eq 0 ]
then
adb disconnect 192.168.56.10${i}
adb connect 192.168.56.10${i}
fi
done
DEVICES=($(adb devices | grep "device$" | sed -e "s|device||g"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment