There's no need to combine
grep and
awk (or
grep and
sed). Just use the one that has the greater flexibility.
Code:
b=$( awk '/em16/ { print $NF }' abc.txt )
b=$( sed -n '/em16/ s/.* //p' abc.txt )
NF in
awk represents the final field, no matter what it is. In the
sed expression "
s/.* //" removes everything up to and including the final space in the line.