tree structure of the data

Hello,

I have a file of the following information ( first field parent item, second field child item)

PM01 PM02
PM01 PM1A
PM02 PM03
PM03 PM04
PM03 PM05
PM03 PM06
PM05 PM10
PM1A PM2A
PM2A PM3B
PM2A PM3C

The output should be like this :
PM01 PM02 PM03 PM04
PM05 PM10
PM06
PM1A PM2A PM3B
PM3C

If anybody is getting some idea, please help me.

Regards,
Thobias

Use recursion.

You will create a function display_child(), which gets the name of the child. This function searches the file for childs and calls display_child() with all the childs it finds.

If the function finds no more childs it creates the output and passes this to the calling function.

I hope this helps.

bakunin

Thanks for your suggestion.
Implemented an awk script and it's working fine.

Regards,
Thobias