Linux – Can awk be used instead

awkbashgreplinux

I would like to get the number from rating as output from this

# nc localhost 9571 
language:
language:en_ZA.UTF-8
language:en_ZW.UTF-8
session-with-name:Ubuntu Classic (No effects):gnome-session --session=2d-gnome
session-with-name:Ubuntu (Safe Mode):gnome-session -f --session=2d-gnome
session-with-name:Ubuntu Classic:gnome-session --session=classic-gnome
xsession:/etc/X11/Xsession
rating:94

I can do it like this

# nc localhost 9571 | grep rating | cut -d: -f2
94

but could awk be used instead for a simpler solution?

Best Answer

$ nc localhost 9571 | awk -F: '/rating/ { print $2 }'