lundi 11 mai 2020

how to split the colon(:) separated string value into next column in csv file using awk or sed

i have below data and i would like to split the colon(:) separated value into next column

Sample data

htttp://example.com, 80
http://lookup/bin/search, 80
testecho345.unix.abc1200.org:8115,80
century.testing.external-abc03:6112,80
century.testing.external-abc03:6112,80
testecho345.unix.abc1200.org:8115,80
testecho345.unix.abc1200.org:8117,80

Desired output

htttp://example.com, 80
http://lookup/bin/search, 80
testecho345.unix.abc1200.org,8115
century.testing.external-abc03,6112
testecho345.unix.abc1200.org,8117

Note: If http then print 80 and https then print 443, if there is any number in the URL then print that number instead 80

Tried below AWK command but not getting expected output.

awk '{split($0,a,":"); print a[1],a[2]}'

Removing the duplicates as well

Thank you for your help in advance.

Aucun commentaire:

Enregistrer un commentaire