Linux commands (9) sort

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.