I’m trying to parse a test file. the file has username, address and phone in the following format:
Name: John Doe1
address : somewhere
phone: 123-123-1234
Name: John Doe2
address : somewhere
phone: 123-123-1233
Name: John Doe3
address : somewhere
phone: 123-123-1232
Only for almost 10k users: ) what I would like to do is convert those rows to columns, for example:
Name: John Doe1 address : somewhere phone: 123-123-1234
Name: John Doe2 address : somewhere phone: 123-123-1233
Name: John Doe3 address : somewhere phone: 123-123-1232
I would prefer to do it in bash but if you know how to do it in python that would be great too, the file that has this information is in /root/docs/information. Any tips or help would be much appreciated.
One way with
GNU awk:Results:
Note that, I’ve set the output file separator (
OFS) to two tab characters (\t\t). You can change this to whatever character or set of characters you please. HTH.