我想从评级中得到数字作为输出
# 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
我可以这样做
# nc localhost 9571 | grep rating | cut -d: -f2 94
但是可以用awk代替一个更简单的解决方案吗?
解决方法
$nc localhost 9571 | awk -F: '/rating/ { print $2 }'