The sort command sorts multiple rows of data in a behavior unit.
For example, there is a text file Test_sort, which has five elements, using the sort command, the five elements can be sorted in dictionary order from small to large.
If the sort command doesn't add anything, the default is to start with the ASCII code value of the first letter, compare the second letter if the first letter is the same, and so on.
In addition to executing the default parameters without having to mark the parameters, sort also provides some options:
-F: Ignore case sort (the system will automatically convert all lowercase letters to uppercase for comparison sort)
-N: Sort numerically (as we all know, the default type of the shell is the character type, and if the default sort is 1123, 132, 23, 312, the system will sort the numbers by dictionary rather than by number, sorted by: Four, 1123, 132, 312, but if you add the parameter-N, the system will sort the four numbers by number size.
-R: Reverse Sort
-T: Specifies the separator, and the specified separator is after-T. The TAB key is the default separator
-K:-K N, which indicates that the comparison begins with the first few fields, the default is from the first letter of the specified field to the end of the line, or you can specify a field interval, separated by commas, such as 2, 3, which indicates that only the characters between the second and third fields are compared, and that general-K and-T are used in conjunction with.
For example, there is a text file Test_sort, which has four lines of content, we selected the separator as the underscore "_", and starting from the second field to compare, sorting results as shown above.
If there's something wrong, please correct me.