Shell programming-sort

Source: Internet
Author: User

Shell programming-sort
The sort sorting operation sorts a row in one or more files according to the set rules. Output to the standard output and will not be saved to any files.
-T specifies the filed separator. The default value is space. Multiple spaces are regarded as one.

-K specifies the number of fields to be sorted. The first field is marked as 1. it can be followed by a range. It can be separated by commas (,), for example,-k, indicating that the first to third fields can be sorted or the characters can be delineated in the field and separated by vertices, for example,-k 1.5 and 1.6 indicate to sort the fifth and sixth given characters in the first field.

-R Reverse Order

-N is sorted by number size. By default, it is sorted by character encoding. Therefore, 10 must be placed before 2. -F ignores the case sensitivity. -B ignores the space at the beginning of the line.

-U removes duplicate rows.

-O specifies the output file.

You can use redirection to output data to other files. to store the results in an input file, you must specify the-o parameter.

Example: sort-t': '-k 3nr/etc/passwd

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.