-1

With the below adb command I am able to get current battery level(as shown in image.

adb shell dumpsys battery | findstr /r /c:level

enter image description here

I am getting response as level: 12

Is there any way to get only value(ie 12 here) instead of level:12?

Shoaib Akhtar
  • 1,393
  • 5
  • 17
  • 46

1 Answers1

0

You can simply use the commands available on Android to get the correct line and then get only the right side of the line:

adb shell "dumpsys battery | grep level | sed 's/^.* \(.*\)$/\1/' "

sed will output what is printed after the last space to the line end.

Robert
  • 39,162
  • 17
  • 99
  • 152