POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html
Sort line wise.
Uses External R-Way merge. This algorithm allows to sort files that are larger than RAM memory.
Sort f1, f2 together line wise:
sort f1 f2
Useful options:
-
-r: reverse order -
-n: numbers -
-u:uniq -
-t:: set field separator to: -
-k5: sort by the Nth field.Example:
sort -k 2,2n -k 4,4hr- sort field
2(from2to2) numerically - sort field
4by human sizes and reverse
From field 2 to 2, numerically, then from 4 to 4, human and reverse
- sort field
-
-R: randomize: pseudo reverse of sorting. -
-h: sort by human readable file sizes like1k,2M,3G -
-f: ignore case -
-fs: ignore case and put always upper before lower -
-b: ignore leading blanks -
-uf: remove duplicates case insensitive -
-m: supposef1andf2are already sorted, making sort faster -
-c: check if is sorted
http://stackoverflow.com/questions/2625976/sorting-space-delimited-numbers-with-linux-bash
No direct way apparently, just tr it.
-
-V: sort dot separated versions numbers:[ "$(printf '10.0\n9.10\n9.9\n' | sort -V)" = "$(printf '9.9\n9.10\n10.0\n')" ] || exit 1