Need assistance with awk/sed to identify/mark duplicate IP addresses
0
votes
3
answers
106
views
Good day.
I have a text file which contains pod/node names and associated IPv6 addresses of which two pods have the same IP address, first pod **k8-worker0001c-cif-9d86d6dd4-vf9b9** and last pod **k8-worker0001c-ctdc-5bc95b699f-xnmrn**, the IP address being **2001:1890:e00f:3900::6**
$ cat /tmp/dup_ip.txt
k8-worker0001c-cif-9d86d6dd4-vf9b9
2001:1890:e00f:3900::4/64 global nodad
2001:1890:e00f:3900::6/64 global
k8-worker0001c-cifpartner-64c89f8bc8-8p5pq
2001:1890:e00f:3900::10/64 global
k8-worker0001c-ctd-7d759784ff-2gk5d
2001:1890:e00f:3900::a/64 global nodad
2001:1890:e00f:3900::d/64 global
k8-worker0001c-ctd-7d759784ff-hd8jp
2001:1890:e00f:3900::c/64 global
k8-worker0001c-ctd-7d759784ff-qkk4t
2001:1890:e00f:3900::8/64 global nodad
2001:1890:e00f:3900::f/64 global
k8-worker0001c-ctd-7d759784ff-t6lwz
2001:1890:e00f:3900::5/64 global
k8-worker0001c-ctd-7d759784ff-vl8x9
2001:1890:e00f:3900::9/64 global nodad
2001:1890:e00f:3900::b/64 global
k8-worker0001c-ctdc-5bc95b699f-xnmrn
2001:1890:e00f:3900::7/64 global nodad
2001:1890:e00f:3900::6/64 global
All I need is a one-liner to identify the duplicate IP address while retaining the rest, including the pod names. I have tried using **awk** **!seen** but that deletes the duplicate which I don't want.
Therefore I'd like something like this:
$ cat /tmp/dup_ip.txt
k8-worker0001c-cif-9d86d6dd4-vf9b9
2001:1890:e00f:3900::4/64 global nodad
2001:1890:e00f:3900::6/64 global DUPLICATE!
k8-worker0001c-cifpartner-64c89f8bc8-8p5pq
2001:1890:e00f:3900::10/64 global
k8-worker0001c-ctd-7d759784ff-2gk5d
2001:1890:e00f:3900::a/64 global nodad
2001:1890:e00f:3900::d/64 global
k8-worker0001c-ctd-7d759784ff-hd8jp
2001:1890:e00f:3900::c/64 global
k8-worker0001c-ctd-7d759784ff-qkk4t
2001:1890:e00f:3900::8/64 global nodad
2001:1890:e00f:3900::f/64 global
k8-worker0001c-ctd-7d759784ff-t6lwz
2001:1890:e00f:3900::5/64 global
k8-worker0001c-ctd-7d759784ff-vl8x9
2001:1890:e00f:3900::9/64 global nodad
2001:1890:e00f:3900::b/64 global
k8-worker0001c-ctdc-5bc95b699f-xnmrn
2001:1890:e00f:3900::7/64 global nodad
2001:1890:e00f:3900::6/64 global DUPLICATE!
Thanks in advance,
Bjoern
Asked by Bjoern
(59 rep)
May 8, 2023, 07:16 PM
Last activity: May 9, 2023, 07:54 PM
Last activity: May 9, 2023, 07:54 PM