Find the answer to your Linux question:
Results 1 to 2 of 2
I need to take a file, put a certain field in ABC order and number each line. After that is finished I need to return the file to it's original ...
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    2

    Sort command help

    I need to take a file, put a certain field in ABC order and number each line.
    After that is finished I need to return the file to it's original order with the numbered field added.

    I am told I need to use sort and gawk.

    I have this so far

    awk '{printf("%5d : %s\n", NR,$0)}' to put the number on each line.

    Anyone help me out?

  2. #2
    Linux User
    Join Date
    Jun 2006
    Posts
    311
    Hi millhouze,
    This sure looks like a homework.

    Read the man page of sort and the following webpages on gawk/awk to "sort it out" : -

    http://hal.csd.auth.gr/thelug/faqs/gawk.html

    http://www.cs.hmc.edu/qref/awk.html

    With Regards,
    Thinker

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...