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.