Assign AWK result to variable [duplicate]
The following works correctly on bash:
a=$(echo '111 222 33' | awk '{print $3;}' ) echo $a # result is "33"
Another option would be to convert the string to an array:
a="111 222 333" b=($a) echo ${b[2]} # returns 333
This might be easier to use for testing with if statement/
INDEXCOUNT="111 222 333"echo $INDEXCOUNT | awk '{if ($3 == 333) print $3}';