获取已连接设备的列表

获取已连接设备的列表

问题描述:

当我在shell中键入adb devices时 我得到这样的东西

when I type adb devices in the shell I get something like this

List of devices attached 
HT06RPQ002T1    device
HT06RPQ002T1    device

我想要一些仅打印电话ID的外壳脚本 例如在这种情况下打印

I want some shell script that will print just the ids of the phones for example in this case to print

HT06RPQ002T1
HT06RPQ002T1

如果连接了更多设备以打印更多ID ...

if more devices are attached to print more ids...

谢谢

编辑

我试图将所有内容放入这样的变量中 asd = adb devices 但我不知道如何解析连接的是一台设备还是十台设备...

I tried to put everything in a variable like this asd=adb devices but I do not have idea how to parse if I have one device attached or I have 10 devices...

adb devices | awk 'NR>1 {print $1}'