Table of Contents

How to use sort command in Linux



sort Options


       -r, --reverse
              reverse the result of comparisons

       -k, --key=KEYDEF
              sort via a key; KEYDEF gives location and type

       -t, --field-separator=SEP
              use SEP instead of non-blank to blank transition

       -u, --unique
              with -c, check for strict ordering; without -c, output only the first of an equal run

       -n, --numeric-sort
              compare according to string numerical value


Examples

$ sort -k 2 -t ":" test.txt

$ sort -k 2,3 -t ":" test.txt

$ sort -k 2 -t ":" -n test.txt