Sort Command

Hello,

We are sorting a huge file (tab delimited) using the "sort" command.
The command is as given below,

sort -o/home/jay/sortres -t\"\t\" +10.0 -11.0 +0.0 -1.0r /home/jay/testsort

Please could anyone tell me ... what exactly will this command do ... i mean, how do these '+10' , '-11' work ..

Thank you,

  • Jay.

from the man pages
man sort

+POS1 [-POS2]
Specify a field within each line to use as a sort-
ing key. The field consists of the portion of the
line starting at POS1 and up to (but not including)
POS2 (or to the end of the line if POS2 is not
given). The fields and character positions are
numbered starting with 0.

   -k POS1[,POS2]
          An alternate syntax for  specifying  sorting  keys.
          The  fields  and  character  positions are numbered
          starting with 1.

   A position has the form f.c, where f is the number of  the
   field  to  use  and c is the number of the first character
   from the beginning of the field \(for \+pos\) or from the end
   of  the previous field \(for -pos\).  The .c part of a posi-
   tion may be omitted in which case it is taken  to  be  the
   first  character  in the field.  If the -b option has been
   given, the .c part of a  field  specification  is  counted
   from  the first nonblank character of the field \(for \+pos\)
   or from the first nonblank character following the  previ-
   ous field \(for -pos\).

   A  \+pos  or  -pos argument may also have any of the option
   letters Mbdfinr appended to it, in which case  the  global
   ordering  options  are not used for that particular field.
   The -b option may be independently attached to  either  or
   both  of the \+pos and -pos parts of a field specification,
   and if it is inherited from the global options it will  be
   attached  to  both.   If  a  -n or -M option is used, thus
   implying a -b option, the -b option is taken to  apply  to
   both  the  \+pos and the -pos parts of a key specification.
   Keys may span multiple fields.

Originally posted by
sort -o/home/jay/sortres -t\"\t\" +10.0 -11.0 +0.0 -1.0r /home/jay/testsort

baiscally +1 -2 means sort on the second field,

i.e +1 mean from the second field it will take they key it will ignore the first key.

-2 means upto the second field.

In your command +0.0 and -1.0r seems to be obsolete for *r* option you can give simply -r remove that +0.0 and try, the result will be the same. The ouput will be sorted in the reverse order (because of -r) based on the 11th field.

Regards
JK