Shell Getting Started-sort sort

Source: Internet
Author: User
Tags gopher

Command: Sort

Option:-t:-kn Specifies that the order is sorted according to a segment here N represents a number, the range specifies n,n. range from N to n

-N in numerical order

-R Reverse Order

-U go to repeat sort

-un numbers are ordered and repeated, and the system considers the letters to be repeated, taking only the first letter string in the document.

Description: Sort, no options are arranged in Asma order.

No Add option

[Email protected] ~]# SORT/ETC/PASSWD
Adm:x:3:4:adm:/var/adm:/sbin/nologin
Aming:x:502:502::/home/aming:/bin/bash
Avahi-autoipd:x:170:170:avahi Ipv4ll Stack:/var/lib/avahi-autoipd:/sbin/nologin
Bin:x:1:1:bin:/bin:/sbin/nologin
Daemon:x:2:2:daemon:/sbin:/sbin/nologin

......

/////////////////////////////////////////////////////////////////////////

-T:-k3


[Email protected] ~]# sort-t:-k3/etc/passwd
Root:x:0: 0:root:/root:/bin/bash
Uucp:x:14:uucp:/var/spool/uucp:/sbin/nologin
OPERATOR:X:0:operator:/root:/sbin/nologin
Bin:x:1: 1:bin:/bin:/sbin/nologin
Games:x:100:games:/usr/games:/sbin/nologin
GOPHER:X:30:gopher:/var/gopher:/sbin/nologin
Ftp:x:14:FTP User:/var/ftp:/sbin/nologin

////////////////////////////////////////////////////////////////////

-N

[Email protected] ~]# sort-t:-k3-n/etc/passwd
Root:x:0: 0:root:/root:/bin/bash
Bin:x:1: 1:bin:/bin:/sbin/nologin
Daemon:x:2: 2:daemon:/sbin:/sbin/nologin
ADM:X:3: 4:adm:/var/adm:/sbin/nologin
LP:X:4: 7:lp:/var/spool/lpd:/sbin/nologin
SYNC:X:5: 0:sync:/sbin:/bin/sync
Shutdown:x:6: 0:shutdown:/sbin:/sbin/shutdown

.......

////////////////////////////////////////////////////////////////////////////

-T:-kn,n For example 3,5 refers to the 3rd paragraph to the 5th paragraph

[Email protected] ~]# sort-t:-k3,5-n/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Bin:x:1:1:bin:/bin:/sbin/nologin
Daemon:x:2:2:daemon:/sbin:/sbin/nologin
Adm:x:3:4:adm:/var/adm:/sbin/nologin
Lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

.......

////////////////////////////////////////////////////////////////////////////////////

-R

[Email protected] ~]# Sort-rn 2.txt
7
6
5
4
3
2
2
1
1
Ac
Ab
Aa

A

/////////////////////////////////////////////////////////////////////////////////////

-U

[Email protected] ~]# sort-u 2.txt
1
2
3
4
5
6
7
A
Ab
Ac

Aa

/////////////////////////////////////////////////////////////////////////

-un

[Email protected] ~]# Sort-un 2.txt
A
1
2
3
4
5
6
7

////////////////////////////////////////////

Summary: sort-t:-kn//-N//-R//-U//-un

Shell Getting Started-sort sort

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.