sed合并两个相邻行
命令:
head tmp.txt |sed '/vni 7804$/{N;s/\n//}'
例子:
[root@A dada]# head tmp.txt
10:41:04.320892 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804
IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 3822356824:3822358234, ack 3220657438, win 1421, length 1410: HTTP
10:41:04.320894 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804
IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 1410:2820, ack 1, win 1421, length 1410: HTTP
10:41:04.320896 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804
IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 2820:4230, ack 1, win 1421, length 1410: HTTP
10:41:04.320898 IP 238.65.57.64611 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804
IP 231.68.223.39358 > 196.113.54.80: Flags [.], seq 193945440:193946850, ack 1902024444, win 1421, length 1410: HTTP
10:41:04.320899 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804
IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 4230:5640, ack 1, win 1421, length 1410: HTTP
[root@A dada]# head tmp.txt |sed '/vni 7804$/{N;s/\n//}'
10:41:04.320892 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 3822356824:3822358234, ack 3220657438, win 1421, length 1410: HTTP
10:41:04.320894 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 1410:2820, ack 1, win 1421, length 1410: HTTP
10:41:04.320896 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 2820:4230, ack 1, win 1421, length 1410: HTTP
10:41:04.320898 IP 238.65.57.64611 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804IP 231.68.223.39358 > 196.113.54.80: Flags [.], seq 193945440:193946850, ack 1902024444, win 1421, length 1410: HTTP
10:41:04.320899 IP 238.65.57.64323 > 238.65.25.4789: VXLAN, flags [I] (0x08), vni 7804IP 231.68.223.38286 > 196.113.54.80: Flags [.], seq 4230:5640, ack 1, win 1421, length 1410: HTTP