当前位置:网站首页>Use of Shell sort command

Use of Shell sort command

2022-04-23 17:06:00 Magic Flute love

sort

sort The order is in Linux It's very useful , It sorts the files , And output the sorting result standard .

Basic grammar

sort ( Options ) ( Parameters )
Options explain
-n Sort by the size of the value
-r In reverse order
-t Set the separator used for sorting
-k Specify the columns to sort

Parameters : Specify the list of files to sort

Case practice

##  Data preparation 
[bd@localServer ~]$ touch sort.sh
[bd@localServer ~]$ vim sort.sh 
bb:40:5.4
bd:20:4.2
xz:50:2.3
ww:10:3.5
ss:30:1.6

###  according to “:” The third column after splitting is sorted in reverse order .
[atguigu@hadoop102 datas]$ sort -t : -nrk 3  sort.sh 
bb:40:5.4
bd:20:4.2
ww:10:3.5
xz:50:2.3
ss:30:1.6

版权声明
本文为[Magic Flute love]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231704450830.html