The--sort of Linux commands

Source: Internet
Author: User

Name: sort
Location:
/usr/bin/sort
permissions: All Users
usage: sort [OPTION] ... [FILE] ...
Sort [OPTION] ...--files0-from=f
Options:
-B--ignore-leading-blanks ignores the front space
-F--ignore-case Fold lower case-to-upper characters ignores letter capitalization
-M--month-sort Compare (unknown) < ' JAN ' < ... < ' DEC ' sorted by month name

-N--numeric-sort Compare according to string numerical value is sorted in pure numbers (by default, sort by text type)

$ cat a11325143$ sort a11133245$ sort-n a13451132      -u--unique the  same data, only one line appears in the $ cat a13513$ sort-u a135

-T--FIELD-SEPARATOR=SEP use SEP instead of Non-blank to blank transition specify delimiter, default to tab delimiter
-K--key=pos1[,pos2] Start a key at POS1 (Origin 1), end it at POS2 (default end of line). See POS syntax below

Specify the interval for sorting
Sort the first field with a colon ":" as the delimiter

head/etc/passwdroot:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/bin/shbin:x:2:2:bin:/bin:/bin/ Shsys:x:3:3:sys:/dev:/bin/shsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/bin/shman:x:6:12: man:/var/cache/man:/bin/shlp:x:7:7:lp:/var/spool/lpd:/bin/shmail:x:8:8:mail:/var/mail:/bin/shnews:x:9:9:news:/ var/spool/news:/bin/sh$ head/etc/passwd| Sort-t ":"-K 1bin:x:2:2:bin:/bin:/bin/shdaemon:x:1:1:daemon:/usr/sbin:/bin/shgames:x:5:60:games:/usr/games:/bin/ Shlp:x:7:7:lp:/var/spool/lpd:/bin/shmail:x:8:8:mail:/var/mail:/bin/shman:x:6:12:man:/var/cache/man:/bin/shnews : X:9:9:news:/var/spool/news:/bin/shroot:x:0:0:root:/root:/bin/bashsync:x:4:65534:sync:/bin:/bin/syncsys:x:3:3: Sys:/dev:/bin/sh The following example shows the importance of-N for the $ cat apa:11:asa:32:capp:5:bstort:1:dpear:4:aahello:3:f$ cat A |sort-t ":"-K 2 pa:11: astort:1:dsa:32:chello:3:fpear:4:aaapp:5:b$ Cat A |sort-t ":"-K 2-n Stort:1:dhello:3:fpear:4:aaapp:5:bpa:11:asa:32:c


The--sort of Linux commands

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.