我想从配置中获取IP地址的列表,我收到它们的格式为:*.*.*.*:*其中最后一个字段是建立的连接的端口号。 我该如何摆脱码头数字? 这里是我现在做这一行:摆脱线匹配模式的结束linux
ss -ta | tail -n +2 |awk '{print $4}' | sort -u
我了解我必须使用SED作为AWK之间的管道和排序冒号后取出一部分,但我不知道如何去做正确的方式。
线ss -ta 返回以下结果:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:ssh *:*
LISTEN 0 100 127.0.0.1:smtp *:*
CLOSE-WAIT 32 0 192.168.1.7:48474 104.18.35.72:https
CLOSE-WAIT 32 0 192.168.1.7:52879 104.18.34.72:https
CLOSE-WAIT 1 0 192.168.1.7:38492 82.80.211.109:http
LISTEN 0 128 :::ssh :::*
LISTEN 0 100 ::1:smtp :::*
ESTAB 0 52 fe80::a00:27ff:fead:6df2%enp0s3:ssh fe80::e1
这是输出到我的命令:
> 127.0.0.1:smtp
> 192.168.1.7:38492
> 192.168.1.7:48474
> 192.168.1.7:52879
> ::1:smtp
> fe80::a00:27ff:fead:6df2%enp0s3:ssh
> :::ssh
> *:ssh
期望的输出是:
> 127.0.0.1
> 192.168.1.7
感谢
2016-03-06
Student
+0
提供一个语料库,和你想要的输出。 –