1.

Solve : Text manipulation help?

Answer»

Hello,

I'm having trouble sorting a text file.

It looks like this:

Code: [Select]Alvaro Costa Daldit Kaur Sings Brian G Heward
Desmond Ogilvie John DER William Gherasim
Lance Mackey Donald Kopplin Robert Mckinlay
Jahir Hussain Mohamed Jack Benaim Abraham Weiss
I WANT it to look like this:

Code: [Select]Alvaro
Costa
Daldit
Kaur
Sings
Brian
G
Heward
I know sed/tr/awk will do this but I dont know how to do it.

Any help?
My knowledge of this topic approaches zero, so there are probably more efficient ways of doing this:

Code: [Select]awk "NR>1{exit};1" c:\temp\text.txt | awk "BEGIN { RS = \" \"} NF {print $0}"

I put your sample code in a file named text.txt. Feel free to change it. This was tested on Win7 so you may have to change the double quotes to single quotes. Only the first line of the data is PROCESSED. To process the ENTIRE file, REMOVE the first AWK.

Results:
Code: [Select]Alvaro
Costa
Daldit
Kaur
Sings
Brian
G
Heward



Discussion

No Comment Found