How to collect all Android device ids in bash script

Hello everyone!

Today I'm going on to share bash script with you, which will help you to collect all android devices id.

deviceList=""
for line in `adb devices | grep -v "List" | awk '{print $1}'`
do
  device=`echo $line | awk '{print $1}'`
  echo "$device"
  if [ $deviceList != "" ]; then
    deviceList="$deviceList,"
  fi
  deviceList="$devicList$device"
done
echo $deviceList

This approach you can use to capture any data from any output.

Have a good day!

Enjoy!