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

Author Topic: Issuue with nawk and split  (Read 748 times)

0 Members and 1 Guest are viewing this topic.

Naisidtheo

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    Issuue with nawk and split
    « on: March 01, 2012, 04:22:55 AM »
    Hi


    using nawk with split does not work as expected.

    I am trying to manipulate the following line field 5 using " ," as field separator.

    Thu Mar 1 08:04:17 2012 , 6759, 9.56, 10.39, 10.05 08:04:18 ,1497 1489 sleeping, 8  jpl 128E , 58E free, 64E taken, 438E

    nawk  -F"," 'BEGIN{split($5, now, " "); print now[0];now[1];now[2]}' "text_file"

    with hope of retrieving 10.05 08:04:18 which I then need to reformat as 10.05, 08:04:18.
    Which then gives me the required columns
    finally saved to a new file as

    Thu Mar 1 08:04:17 2012 , 6759, 9.56, 10.39, 10.05, 08:04:18 ,1497 1489 sleeping, 8  jpl 128E , 58E free, 64E taken, 438E

    Any tips will be very much appreciated.

    Thanks
    naisidthe


    Rob Pomeroy



      Prodigy
    • Systems Architect
    • Thanked: 123
      • Me
    • Experience: Expert
    • OS: Other
    Re: Issuue with nawk and split
    « Reply #1 on: March 14, 2012, 05:37:58 AM »
    nawk?  What operating system is this?  Which distribution?
    Only able to visit the forums sporadically, sorry.

    Author of the fantasy thriller, Insensate - available for all ebook readers and iDevices. Find out more >here<. Only 99p/99¢!