View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#9
Originally Posted by fhutt View Post
Maybe this line:
current = ((bmestat | grep "battery current") | awk '{print $3}' )
is too complicated for someone like me, who knows very little about sh or python.
But maybe split the job up into 3 smaller pieces would be easier:

#!/bin/sh
#Place the output of bmestat into string bmestring
bmestring = bmestat

#Extract the 'battery current' element out of the string in bmestring
element = ($bmestring | grep "battery current")

#Extract the numeric value out of element
current = ($element | awk '{prit $3}')
echo -n $current

Now you can see my lack of knowledge.
Maybe it would be easier in python.
Can someone please help put me out of my misery with this?
Thanks
Just one set of braces is enough

current=$(bmestat | grep "battery current" | awk '{print $3}' )
 

The Following User Says Thank You to juiceme For This Useful Post: