Bash "sort" command problem
I am trying to use a piece of scientific software that involves executing a number of scripts and commands.There is a particular step I am stuck on, where the program needs a file to be sorted and the documentation gives the command:
sort +3 -25 file1 >file2 The options +3 and -25 do not seem to correspond to any of the options for "sort" when I look at the help in bash. Am I missing something simple here? Is this not actually a bash command and something else? Unfortunately the documentation does not explain the way in which the data needs to be sorted, so I am unable to implement my own solution. I am fairly new to using bash and linux in general and am completely stuck. Any help appreciated! |
Quote:
|
sort is a separate program and not something internal to bash. The command line you were given uses an obsolete syntax, and specifies a sort beginning with field 3 and extending up to but not including field 25, where the fields are numbered from 0. The current manual page for sort no longer describes this syntax, though the sort command itself does still accept it. You can find a page that includes the obsolete syntax here.
The modern equivalent would be Code:
sort -k4,25 file1 >file2 |
I think they are key field numbers and are somehow similar to the values presented with -k only that the position is n + 1. e.g. sort +3 -25 is similar to sort -k4,25. The numbers presented in -k represent the key fields of the line which are prioritized in sorting before the whole line is sorted in general.
So if I have a file containing Code:
aaa def ghi Code:
sort +1 -3 file.txt Code:
bbb abc ghi Code:
sort +1 -2 file.txt Code:
aaa abc jkl |
Try reading "info sort". It describes the usage of the program in a lot more detail than the manpage.
This is true of most info pages, by the way. |
Just a bump to say thank you to the replies - answered my question perfectly (especially konsolebox!).
|
All times are GMT -5. The time now is 08:41 AM. |