1. Role
Sorts according to the different data types, which can be sorted by the behavior units for the contents of the text file.
2. Usage
Sort "parameter" "File or stdin"
Parameters :
-F: Ignores case differences, such as a and a are treated as encodings, and lowercase letters are converted to uppercase letters for comparison;
-B: Ignores all blank parts preceding each line, starting from the first visible character;
-M: The name of the month to sort, the first 3 letters according to the abbreviation of the month to sort, such as Jan less than the Feb;
-N: Sort by using "pure number" (by default it is sorted by type of text);
-R: Reverse sort;
-U: Is Uniq, in the same data, only one row is represented;
-t< delimited character;: delimiter, by default the [tab] key is used to separate;
-K: Sort by that interval (filed);
-o< output File >: The sorted result is stored in the specified file.
3. Give examples
3.0 sort file or cat file | Sort
Compare each line of a file as a unit, comparing it from the first character to the ASCII value, and finally outputting them in ascending order:
3.1 sort-f File
Ignoring case differences, such as a and a as encodings, convert lowercase letters to uppercase letters for comparison:
3.2 Sort-b File
Ignores all blank parts preceding each line, starting with the first visible character:
3.3 Sort-m File
Sort by the name of the month, sorting the first 3 letters according to the abbreviation of the Month:
3.4 sort-n File
Use "pure numbers" to sort (by default, sort by text type):
3.5 sort-r File
Reverse Sort:
3.6 Sort-u File
The same data only appears on one line:
3.7 sort-t ': '-K 3 file
The contents are separated by: to be sorted in the third column:
3.8 Sort File-o Result
To deposit the sorted result into the result file:
Linux commands (9) sort