netstat:解析(awk?)输出到 return "Program name" 而不是 "PID/Program name"

netstat: parse (awk?) output to return "Program name" not "PID/Program name"

UBUNTU 14.04

netstat -p 在同一列中输出两个 "PID/Program name"。我只想在该列中显示 "Program name"。最简单的方法是什么?

实际输出

root@neo4j1:~# netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *:ssh                   *:*                     LISTEN      1020/sshd
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1020/sshd
tcp6       0      0 [::]:7473               [::]:*                  LISTEN      31380/java
tcp6       0      0 [::]:7474               [::]:*                  LISTEN      31380/java

期望输出

root@neo4j1:~# netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       Program name
tcp        0      0 *:ssh                   *:*                     LISTEN      sshd
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      sshd
tcp6       0      0 [::]:7473               [::]:*                  LISTEN      java
tcp6       0      0 [::]:7474               [::]:*                  LISTEN      java

尝试

netstat -tlp | sed 's,[0-9]\+/,,'

使用 Sed 分组:

netstat -tlp | sed 's/\(^.*\)\( [0-9]*\/\)\(.*$\)//g'

虽然 RTLinuxSW 的答案更清晰。