Take the list of attached devices

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

List of devices attached 
HT06RPQ002T1    device
HT06RPQ002T1    device

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

HT06RPQ002T1
HT06RPQ002T1

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

Thanks

EDIT

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...

Answers


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

flag=false

while read -r device type
do
    if ! $flag
    then
        flag=true
        continue
    fi
    echo "$device"
done < <(adb devices)

Need Your Help

Improve performance of searching JSON object with jQuery

javascript jquery json

Please forgive me if this is answered on SO somewhere already. I've searched, and it seems as though this is a fairly specific case.

How to use mongoDB with Solr?

mongodb solr mongoid

Is it possible to replicate data from mongoDB to Solr? I'm using ruby + sinatra + mongoid. Or i need to make hooks with after_create, after_update and so on through rsolr?