westwood01
Technical User
First off, this site is such an amazing resource. Thanks to you all.
Suppose I have an input.file that looks like:
homer: server1:/var/legato/rman/bin/ebuarch.PRTLDEV
homer: server1:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server1:/var/legato/rman/bin/ebuarch.PRTLQA
homer: server2:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server2:/var/legato/rman/bin/ebuarch.EP88QA
Using awk or sed how can I get the file to look like:
homer: server1:/var/legato/rman/bin/ebuarch.PRTLDEV
homer: server1:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server1:/var/legato/rman/bin/ebuarch.PRTLQA
homer: server1:ALL
homer: server2:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server2:/var/legato/rman/bin/ebuarch.EP88QA
homer: server2:ALL
If only field $2 (server1 for example) is duplicated, a line is added below the last like line to read "homer: server1:ALL" for example.
`awk -F":" '{print $2}' input.file` gives me a listing of all the server names, but I am unsure how to check for dups and add a line if dups exist.
Suppose I have an input.file that looks like:
homer: server1:/var/legato/rman/bin/ebuarch.PRTLDEV
homer: server1:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server1:/var/legato/rman/bin/ebuarch.PRTLQA
homer: server2:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server2:/var/legato/rman/bin/ebuarch.EP88QA
Using awk or sed how can I get the file to look like:
homer: server1:/var/legato/rman/bin/ebuarch.PRTLDEV
homer: server1:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server1:/var/legato/rman/bin/ebuarch.PRTLQA
homer: server1:ALL
homer: server2:/var/legato/rman/bin/ebuarch.PRTLPROD
homer: server2:/var/legato/rman/bin/ebuarch.EP88QA
homer: server2:ALL
If only field $2 (server1 for example) is duplicated, a line is added below the last like line to read "homer: server1:ALL" for example.
`awk -F":" '{print $2}' input.file` gives me a listing of all the server names, but I am unsure how to check for dups and add a line if dups exist.