1

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?

  • 1
    Writing code would be a good start. Some combo of `adb`, `tail`, and `awk` will probably do the trick. – Marc B Jul 17 '14 at 17:37

1 Answers1

2

Through grep,

adb devices | grep -o '\b[a-f0-9]\+\b'
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274