Contents / Previous / Next


Sort Lines of Text Files (sort)

Write sorted concatenation of all FILE(s) to standard out­ put.
       sort [OPTION]... [FILE]...

Ordering options:

       -d, --dictionary-order
             consider only blanks and alphanumeric characters

       -f, --ignore-case
              fold lower case to upper case characters

       -g, --general-numeric-sort
              compare according to general numerical value

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

       -r, --reverse
              reverse the result of comparisons

       -k, --key=POS1[,POS2]
              start a key at POS1, end it at POS 2 (origin 1)

       -o, --output=FILE
              write result to FILE instead of standard output

       -S, --buffer-size=SIZE
              use SIZE for main memory buffer

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

Example:

Try: 

> ls -a >ls.out

> cat ls.out | sort -n -k 5