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

This is a discussion on help with sorting sequence in Unix C:sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list within the Tech Board forums, part of the Community Boards category; sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list Thanks...

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

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

    sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list
    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Is this supposed to be a question?

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    12

    editor:back to topic

    Quote Originally Posted by tabstop View Post
    Is this supposed to be a question?
    Yes.

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

    --------------------------------------------------------------------------------

    Hi List is
    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

    How does it do it?
    sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So if you want to know what the options to sort are, read the man page on sort. If you want to know the internals of sort, you can probably find GNU source or BSD source somewhere. If you want to know what any of this has to do with C, well, so do I.

    Edit: And a bonus hint: that ':' you have is probably a bad copy of somebody's hand-written IBM-style broken pipe character for '|'. (My keyboard, at least, shows a broken pipe on the key itself, so that's probably what you're looking at.)

    Edit edit: Or do you mean the c shell?
    Last edited by tabstop; 08-25-2008 at 09:37 PM.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    This is a GREAT example of how NOT to ask a question. Sheesh!

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    12

    Hi everyone

    Please stop showing off ur whacky IQ.Obviously i checked the man pages on sort.If u guys cant be helpful,keep your mouth shut and be humble instead of pinpointing others' small mistakes.U ll do better than this.U egoistic punks.This forum is supposed to help people learn and not point out stupid mistakes.Fools

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    12
    Quote Originally Posted by gurvinder View Post
    Please stop showing off ur whacky IQ.Obviously i checked the man pages on sort.If u guys cant be helpful,keep your mouth shut and be humble instead of pinpointing others' small mistakes.U ll do better than this.U egoistic punks.This forum is supposed to help people learn and not point out stupid mistakes.Fools
    U guys cant help and try to show off ur creativity by elaborating on metaphors between broken pipes and IBM style crap.nuts

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    12

    Thumbs down

    Quote Originally Posted by arpsmack View Post
    This is a GREAT example of how NOT to ask a question. Sheesh!
    I dont mind getting banned from this forum for speaking the truth

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    I point out my own stupid mistakes all the time... ON THESE FORUMS!

    I'll tell you what, if you can settle down there, realize that your first post didn't make sense whatsoever, and write two or three legible sentences followed by a meaningful question, I will try to help you.

    But I can't help you if I have no idea what you're going on about.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,410
    gurvinder, you may have checked the relevant documentation, but your posts show nothing of the sort. Present your question clearly, state what you are having problem with and what you have tried to solve/understand the problem so that people can see that you have put in effort.

    Your response warrants an official warning according to the forum guidelines, but I shall hold it off since you are new and perhaps did not understand the responses you got.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So apparently your question is about the options after all. (Note that in two whole posts you managed to NOT MENTION WHAT YOUR BLEEDING QUESTION WAS IN ANY WAY WHATSOEVER. Note that this is not a "small mistake" but the largest mistake you can actually make on a help forum. And it turns out that prodding you with questions was in fact helpful, since it made you actually TELL US WHAT YOUR QUESTION IS. Thank you for your consideration of this matter.)

    But if you had read the man page, you would have seen this:
    Quote Originally Posted by sort man page

    `-n'
    Sort numerically: the number begins each line; specifically, it
    consists of optional whitespace, an optional `-' sign, and zero or
    more digits possibly separated by thousands separators, optionally
    followed by a radix character and zero or more digits. The
    `LC_NUMERIC' locale specifies the radix character and thousands
    separator.

    `sort -n' uses what might be considered an unconventional method
    to compare strings representing floating point numbers. Rather
    than first converting each string to the C `double' type and then
    comparing those values, sort aligns the radix characters in the two
    strings and compares the strings a character at a time. One
    benefit of using this approach is its speed. In practice this is
    much more efficient than performing the two corresponding
    string-to-double (or even string-to-integer) conversions and then
    comparing doubles. In addition, there is no corresponding loss of
    precision. Converting each string to `double' before comparison
    would limit precision to about 16 digits on most systems.

    Neither a leading `+' nor exponential notation is recognized. To
    compare such strings numerically, use the `-g' option.

    `-t SEPARATOR'
    Use character SEPARATOR as the field separator when finding the
    sort keys in each line. By default, fields are separated by the
    empty string between a non-whitespace character and a whitespace
    character. That is, given the input line ` foo bar', `sort'
    breaks it into fields ` foo' and ` bar'. The field separator is
    not considered to be part of either the field preceding or the
    field following.

    `+POS1[-POS2]'
    The obsolete, traditional option for specifying a sort field.
    The field consists of the line between POS1 and up to but _not
    including_ POS2 (or the end of the line if POS2 is omitted).
    Fields and character positions are numbered starting with 0.
    See below.
    Obviously I didn't copy the options you didn't use. (I really shouldn't have bothered doing this, but I'm a giver.)

    Edit: And obviously the shouting isn't really called for, since you all seem to have had the good conversation while I was cutting and pasting. I apologize.
    Last edited by tabstop; 08-25-2008 at 10:20 PM.

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by gurvinder View Post
    U guys cant help and try to show off ur creativity by elaborating on metaphors between broken pipes and IBM style crap.nuts
    That was no metaphor -- that was deadly serious. (I've always heard it called IBM-style even though there's no mention of it at the link -- just EBCDIC, which I guess is close enough.)

  13. #13
    Registered User
    Join Date
    Jul 2008
    Posts
    12
    Quote Originally Posted by tabstop View Post
    So apparently your question is about the options after all. (Note that in two whole posts you managed to NOT MENTION WHAT YOUR BLEEDING QUESTION WAS IN ANY WAY WHATSOEVER. Note that this is not a "small mistake" but the largest mistake you can actually make on a help forum. And it turns out that prodding you with questions was in fact helpful, since it made you actually TELL US WHAT YOUR QUESTION IS. Thank you for your consideration of this matter.)

    But if you had read the man page, you would have seen this:

    Obviously I didn't copy the options you didn't use. (I really shouldn't have bothered doing this, but I'm a giver.)

    Edit: And obviously the shouting isn't really called for, since you all seem to have had the good conversation while I was cutting and pasting. I apologize.
    Thanks TABSTOP.Can someone or u please clarify the following
    In this case
    --------------------------------------------------------------------------------

    Question Repeat:
    Hi List is
    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

    How does sort do it?
    sort -t '|' +0 -1 -n +1 -2 +2 -3 -o list list


    According to the following :

    `+POS1[-POS2]'
    The obsolete, traditional option for specifying a sort field.
    The field consists of the line between POS1 and up to but _not
    including_ POS2 (or the end of the line if POS2 is omitted).
    Fields and character positions are numbered starting with 0.
    See below.



    Then if u see the sort cmd,the sorting will take place between +1 and upto but not including - 2.Now this is confusing what field will refer to 000 or 2008-07-17.
    The field 000 is Field 1 and 2008-07-17 is Field 2.Sorting will take place according to which field and what algorithm ,numerical order or what?

  14. #14
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    Fields and character positions are numbered starting with 0.
    Reading for comprehension is not your strong point I gather.

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    And I noticed you fixed the | for :. So we start by sorting field 0 (up to but not including 1, so just field 0), numerically (that's what -n says, right there in what I copied), then field 1, then field 2.

Page 1 of 2 12 LastLast
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, 01:45 AM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 09:16 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21