I was porting over a script from AIX to linux that had code of the form
grep <pattern> $LOG | sort -b +rn4 -5 +2 -3
On AIX, this kind of sort syntax is documented, and basically the +a -b syntax means skip a fields and consider fields between a and b as your sort key.
This didn't work on linux, because the linux sort command didn't like including the 'rn' (reverse numeric) flags in the +a 'skip fields' parameter. but this did work:
grep <pattern? $LOG | sort -b -rn +4 -5 +2 -3
So apparently the 'field skipping logic is supported by linux sort, but not documented in the man page (that I could see, anyway). the -k option works on both systems to specify a key field number. But here's a weird quirk. On AIX
ls -l | sort -n +4
produces a list of files sorted on the 5th field (size). But on linux, the same command produces an error:
sort: cannot read: +4: No such file or directory
ls -l | sort -n +4 -5
does work, though. So, apparently the + skip - skip key-selection syntax sort of works, but only if you specify both the starting and ending column skip parameters. And it's not documented. So, my question - is this column skipping syntax deprecated? Does it just work because the code was just there in the command and nobody knew to take it out?