View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#15
Originally Posted by fhutt View Post
Yes, you're right that does work.
This is what I had:

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

echo $current

Note the spaces before and after the = sign and another space before the last bracket.
Yes, that was the problem

Shell scripts are notorious in having certain places that you must have whitespace, like conditional expressions, and certain places that you cannot have whitespace, like in variable assignments...

That's the reason why script programming is such an esoteric art, usually beginners have easier time learning some true high-level language like python which has fairly predictable use of whitespace (namely, only as a block forming method, but note that even there is the huge difference between a space and a tab...)