Sort command is helpful to sort/order lines in text files. You can sort the data in text file and display the output on the screen, or redirect it to a file. Based on your requirement, sort provides several command line options for sorting data in a text file.
$ sort [-options]
- -M: compare (unknown) < `JAN' < ... < `DEC'
- -h: compare human readable numbers (e.g., 2K 1G)
- -n: compare according to string numerical value
- -r: reverse the result of comparisons
- -k: start a key at POS1 (origin 1), end it at POS2 (default end of line).
- -o: write result to FILE instead of standard output