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
I am getting response as level: 12
Is there any way to get only value(ie 12 here) instead of level:12?
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
I am getting response as level: 12
Is there any way to get only value(ie 12 here) instead of level:12?
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.
© 2022 - 2025 — McMap. All rights reserved.