I have two fields like this
Field1 : Field2 – I have them stored in a file like this:
X : 1234
X : 4321
Y : 123
Z : 1234
Z : 4321
Z : 357
I want to transform that into this:
X : 1234
4321
Y : 123
Z : 1234
4321
357
For a given field1 field2 will be different , i.e X can’t have 1234 and again 1234 but two different field1’s can have the same field2, like X and Z having 1234 and 4321.
How do I go about filtering my input file to the get the required output file using BASH/KSH?
output: