Get device information (such as product, model) from adb command

AndroidAdb

Android Problem Overview


One way to achieve this is as follows:

adb devices -l

example output:

123abc12               device product:<id> model:<id> device:<id>
456abc45               device product:<id> model:<id> device:<id>

But this list's out all devices connected, but I want to get the information for a specific device.
I want information only about "123abc12". The output should be:

123abc12               device product:<id> model:<id> device:<id>

The second device should not be shown.
I have the device name i.e 123abc12, and it can be used to get the required information, but I don't know how.
Thanks.

Android Solutions


Solution 1 - Android

The correct way to do it would be:

adb -s 123abc12 shell getprop

Which will give you a list of all available properties and their values. Once you know which property you want, you can give the name as an argument to getprop to access its value directly, like this:

adb -s 123abc12 shell getprop ro.product.model

The details in adb devices -l consist of the following three properties: ro.product.name, ro.product.model and ro.product.device.

Note that ADB shell ends lines with \r\n, which depending on your platform might or might not make it more difficult to access the exact value (e.g. instead of Nexus 7 you might get Nexus 7\r).

Solution 2 - Android

Why don't you try to grep the return of your command ? Something like :

adb devices -l | grep 123abc12

It should return only the line you want to.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDestructorView Question on Stackoverflow
Solution 1 - AndroidSimo KinnunenView Answer on Stackoverflow
Solution 2 - AndroidSubstitutView Answer on Stackoverflow