The title doesn't give the question justice. I'm writing a shell script, for use in conky, to get the status of my mouse and keyboard's battery. Previously, I used upower to do this:
dev=`upower -e | grep "mouse_"`
upower -i $dev | grep 'state' | cut '-c26-36'
As you can see, I used the cut command to trim the result as it's position never changed.
However, today I found a bug in upower. It cannot see my mouse being charged. So, I have installed solaar from github which does display the correct status. But I'm not sure how to trim the result:
solaar show mouse | grep 'Battery'
# outputs "Battery: N/A, recharging."
I cannot use cut anymore because the segment 'N/A' has an arbitrary length.
Ideally, I'd like the script to output any word which follows the first comma.
How can I do this?