Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Text manipulation help  (Read 4229 times)

0 Members and 1 Guest are viewing this topic.

galford

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    Text manipulation help
    « on: September 14, 2014, 05:49:39 AM »
    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?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Text manipulation help
    « Reply #1 on: September 14, 2014, 09:52:39 AM »
    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

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein