Sort command
Sort is output in ascending order of ASCII code, and is compared sequentially from the first character
Common options
-C test file is already sorted
-R Reverse Sort
-N Sort by numeric numeric size
-t Specifies the separator
-K Specify Domain
-U removes duplicate rows from the result
-m merge two sorted files
-O writes output to the specified file
(1)-u sort after removing duplicate rows
# Cat 1.txt1:datadir=/aaa/zzz:2:basedir=:cc4:datadir=/sdfsfsd:dd3:basedir=/data:ggsnsdsnsdsnsdsnsdsnsdsnsd# Cat 1. TXT | Sort-u1:datadir=/aaa/zzz:2:basedir=:cc3:basedir=/data:gg4:datadir=/sdfsfsd:ddsnsdsnsdsnsd
(2)-N
# cat 2.txt110111925# Cat 2.txt | Sort ---> #sort是按照ASCII码升序输出, 110111925# cat 2.txt | sort-n ---> #为实现纯数值排序可用-n from first character backwards Option Implementation 125101119
(3)-R reverse Order
# Cat 2.txt | Sort-n-r191110521
(4)-t-k
# cat-n 3.txt1 banana:30:5.52 apple:10:2.53 pear:90:2.34 orange:20:3.4# cat 3.txt | sortapple:10:2.5banana:30:5.5orange:20:3.4pear:90:2.3# Cat 3.txt | Sort-t ': '-3-n ---> #以: As a delimiter, sorted by the numeric size of the 3rd field pear:90:2.3apple:10:2.5orange:20:3.4banana:30:5.5# Cat 3.txt | sort -T ': '-K 3-n-R ---> #以: for delimiters, reverse-order the numeric size of the 3rd field banana:30:5.5orange:20:3.4apple:10:2.5pear:90:2.3
[Shell Foundation]--sort Command