Sort function: Sorts the contents of a file line by row, if the first letter of the two lines is the same, continues to compare the next character of the two lines, and so on
Syntax: sort [Options] File
Sort sorting is the inverse of all the rows in the specified file and displays the results on standard output, such as not specifying an input file or using "-", which means that the sorted content is from the standard input
Sort sorting is done based on the comparison of one or more key words drawn from the input row, the smallest sequence of characters used to sort the sort keys, and by default, sorted in ASCII character order for the entire row
The options for changing the default settings are:
-M if the given file has been sequenced, merge the files.
-C Check whether the given file is ordered, if not, print error message, with a status value of 1 exit
-U leaves only one row for rows that are considered identical after sorting.
-O output file, writes the sort output to the output file instead of the standard output, if the output file is one of the input files, sort first writes the contents of the file to a temporary file, and then sorts and writes the output results
The options for changing the collation include:
-D is sorted in dictionary order, meaning the comparison of male letters, numbers, spaces, and tabs
-F Treats lowercase letters equal to uppercase
-I ignores nonprinting characters
-M as a month comparison: "JAN" < "FEB"
-R output sorting results in reverse order
+POSL-POS2 specifies one or more fields as the sort key, the field position starts from POS1, and until Pos2 (including POS1, excluding Pos2). If you do not specify POS2, the keyword is from pos1 to the end of the line. The position of the field and character starts at 0.
-B ignores leading blanks (spaces and tabs) when looking for keywords in each row.
-T separator Specifies the character separator as the field delimiter
This article is from the "Ride a Pig to Travel" blog, please be sure to keep this source http://songqinglong.blog.51cto.com/7591177/1706875
The use of sort in Linux