Shell Sort Command-sort

Source: Internet
Author: User

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.

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.