Shell programming-sort
The sort sorting operation sorts a row in one or more files according to the set rules. Output to the standard output and will not be saved to any files.
-T specifies the filed separator. The default value is space. Multiple spaces are regarded as one.
-K specifies the number of fields to be sorted. The first field is marked as 1. it can be followed by a range. It can be separated by commas (,), for example,-k, indicating that the first to third fields can be sorted or the characters can be delineated in the field and separated by vertices, for example,-k 1.5 and 1.6 indicate to sort the fifth and sixth given characters in the first field.
-R Reverse Order
-N is sorted by number size. By default, it is sorted by character encoding. Therefore, 10 must be placed before 2. -F ignores the case sensitivity. -B ignores the space at the beginning of the line.
-U removes duplicate rows.
-O specifies the output file.
You can use redirection to output data to other files. to store the results in an input file, you must specify the-o parameter.
Example: sort-t': '-k 3nr/etc/passwd