MakeThingsHappen
MakeThingsHappen

Reputation: 65

Get only android device id and save it to an array in bash

I am new to bash scripting and I want to write a script that gets only the device id from the bash output when I do:

adb devices

Result:-

List of devices attached 
06c3b9270b3fa34c    device

So in my array i only need 06c3b9270b3fa34c.

How can i write this in bash?

Upvotes: 1

Views: 1676

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

Through grep,

adb devices | grep -o '\b[a-f0-9]\+\b'

Upvotes: 2

Related Questions