Introduction to Linux Sort programs __linux

Source: Internet
Author: User

1. Introduction

The sort command sorts the rows in the files specified by the file parameter and writes the results to the standard output. If the file parameter specifies multiple files, the sort command connects the files and sorts them as a file. Sort compares each row of the file as a unit, comparing it to each other, from the first character backwards, sequentially by the ASCII code value, and finally outputting them in ascending order.


2. Command Parameters

-U remove duplicate rows in output line
-F ignores case differences, such as a and a as encoding;
-B ignores the spaces portion of the front;
-M is sorted by the name of the month, such as the sorting method of a few years, DEC, etc.
-n Sorts using pure digits (the default is to sort by text);
-O because sort defaults to output the results to standard output, redirection is required to write the results to a file, in the form of sort filename > newfile;
-R reverse Sort;
-T separator, which by default is delimited by the [tab] key;
K to sort by that interval (field)


3, Example

1 the/ETC/PASSWD account to order

cat/etc/passwd | Sort


Reference: Baidu Library

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.