By Alvin Alexander. Last updated: July 31, 2016
Wow, the Linux sort
command changed while I was away. A sort
command that I used to write like this (as well as I can remember):
grep 'foo bar' *.html | sort -d: -f2 -n
is now written like this:
grep 'foo bar' *.html | sort -t ':' -n -b +2
In english this means "Extract all records containing the string 'foo bar' from all files ending with the '.html' extension (using the grep command). Then sort those records numerically, by the second field, where fields are separated by the ':' character, and ignore leading spaces when doing the sort."
These sort
command options are the same on both my Mac (OS X 10.4) and a Linux server that I use. Reading the sort man page, this is the correct POSIX style.