Thread: help with sorting sequence in Unix C:sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list

  1. #16
    Registered User
    Join Date
    Jul 2008
    Posts
    12

    Thanks Tabstop and rags to riches.

    1 very stupid question
    sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list
    will the Field 1 that is 2008-07-17| be sorted in numerical order?
    I always thought the parameter -n is only meant for fields mentioned preceding it.that is +0 -1 ?

    000|2008-07-17|556543|RTJ|35-RTGJ|EYT
    465|2008-11-10|567789|GHJ|45-DGHH|ETU
    533|2008-09-06|567789|GHJ|45-DGHH|ETU
    Then
    sort -t ':' +0 -1 +1 -2 -n +2 -3 -o list list would mean the same thing.I also gotta learn that the field 000 is Field 0.
    Is it the same case with awk '|' print $1 on the line 000|2008-07-17|556543|RTJ|35-RTGJ|EYT .Will it print 2008-07-17?
    Thanks a lot,

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You don't want field 1 (the dates) sorted in numerical order. It's currently sorted in lexicographic (alphabetical) order, which is convenient since that automatically sorts yyyy-mm-dd in proper chronological order.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  3. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM