请未如何截取netstat的最后一列

作者: alctel999 2014-04-18 19:46:11
[root@localhost: ~]#netstat -tupln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2022/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2033/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1515/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2045/sendmail: acce
..........
..........
udp6 0 0 :::4605 :::* 3184/dhclient
udp6 0 0 :::920 :::* 2022/rpcbind
udp6 0 0 :::111 :::* 2022/rpcbind

我只想在脚本里取得pid/program name列下的2022 2033 1515 2045 3184.......这些数据
但是netstat -tupln | cut -d ' ' -f 8
和netstat -tupln | awk '{print $1}'都失败了 不信大家可以事是
请问我该怎么办

相关资讯