我有以下 VPN 隧道状态的输出:
[root@localhost:~]# setkey -D
82.113.11.226 10.18.1.201
esp mode=tunnel spi=143937423(0x08944f8f) reqid=0(0x00000000)
E: 3des-cbc c114543c 3049e8b8 c033e4ea 07e0054e 3e8ac254 f0dbb7f5
A: hmac-md5 8461e21b 2318bb9c 352bee1d e24a0a53
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Jan 28 09:52:41 2013 current: Jan 28 09:56:58 2013
diff: 257(s) hard: 3600(s) soft: 2880(s)
last: Jan 28 09:52:49 2013 hard: 0(s) soft: 0(s)
current: 852(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 11 hard: 0 soft: 0
sadb_seq=1 pid=12264 refcnt=0
10.18.1.201 82.113.11.226
esp mode=tunnel spi=3053715472(0xb6040010) reqid=0(0x00000000)
E: 3des-cbc 28c87550 a6c9a17b 37ad0b02 03567617 79647aeb 644563d8
A: hmac-md5 0ef83de9 1b279a16 658eb176 dad37d50
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Jan 28 09:52:41 2013 current: Jan 28 09:56:58 2013
diff: 257(s) hard: 3600(s) soft: 2880(s)
last: Jan 28 09:52:41 2013 hard: 0(s) soft: 0(s)
current: 1524(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 19 hard: 0 soft: 0
sadb_seq=0 pid=12264 ref
我想取只包含 ip 地址的行,并比较第一行的左边部分是否与第二行的右边部分相等,这是空格分隔的,反之亦然。第一步,我做了以下命令:
[root@localhost:~]# setkey -D | sed -n '/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/p'
82.113.11.226 10.18.1.201
10.18.1.201 82.113.11.226
线条对空间感兴趣。任何人都可以建议任何 awk 或 sed 表达式来做到这一点吗?