[Linux] Sort command

Source: Internet
Author: User

Sort command

Delimiter number

If this parameter is not specified, spaces are separated by default, and spaces at the beginning and end are ignored. If this parameter is specified, only one character can be recognized. If this parameter is set to a space character, spaces at the beginning and end are not ignored. For example, if a line of content is "X" and no parameter is specified, only one field is considered. If space is specified as the separator, three fields are available, and the first and third fields are empty.


How to enter a tab <tab>? A lot of data uses the <tab> character as the field separator. However, if you enter <tab> In the interactive shell, this character is not displayed, because the default function of <tab> is completion and prompt. The solution is to press ctrl + v, and then press <tab> or ctrl + I to display the <tab> character in the command line.


Specify the sorting Field(Multiple-k parameters can be specified.
Set the comparison priority in the order of appearance)

Each line may be separated by a separator into multiple fields. Which field has a higher priority? The value can be indicated by the-k parameter. And multi-field sorting in Excel.

The parameter is in the form of a number + modifier. Note that the number is based on 1.


-K2 # Compare the second field to the end of the record

-K2.3, 4.5 # starts from the third character of the Second Field and starts from the fifth character of the fourth field.

-K2, 2nr #
Only compare the second field, and regard it as a number, and sort it in inverted order (if it is small to big by default, this is from large to small)


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.