shell - What does `sort +0 -1` do? -
i have old script contains variant of sort +0 -1, man sort in system not mention existence of these options.
from another question, led the wikipedia page sort , says:
in old versions of sort,
+1option made program sort using second column of data (+2third, etc.). deprecated, , instead-koption can used same thing.
but not mention negative argument such -1 supposed do.
note that, in "modern" sort (gnu coreutils 8.21), sort +0 -1 works, while of following fail: sort +0 +1, sort -0 -1, , sort -0 +1.
i can add pairs of numbers (e.g. sort +0 -1 +2, sort +0 -1 +2 -3), short test case cannot precisely infer meaning.
edit: completeness, nowadays invalid command such sort +0 +1 equivalent sort -k1 -k2.
as per gnu info page on sort:
on older systems, ‘sort’ supports obsolete origin-zero syntax ‘+pos1 [-pos2]’ specifying sort keys. obsolete sequence ‘sort +a.x -b.y’ equivalent ‘sort -k a+1.x+1,b’ if y ‘0’ or absent, otherwise equivalent ‘sort -k a+1.x+1,b+1.y’.
therefore, sort +0 -1 equivalent sort -k 1,1 in newer systems.
Comments
Post a Comment