linux之在当前目录下按照文件大小进行排序的三种方法

当前目录下按照文件大小排序 

[root@test23 script]# ls -lSh

总用量 44K

-rw-r--r-- 1 root root 2.4K 12月 8 17:24 test.conf

-rw-r--r-- 1 root root 1.3K 11月 30 16:05 count_pig.sh

-rw-r--r-- 1 root root 1.3K 12月 21 20:31 count_pig.sh.bak

-rw-r--r-- 1 root root 1.2K 1月 24 15:18 get_holiday.sh

-rw-r--r-- 1 root root 853 12月 6 12:23 two_points.sh

-rw-r--r-- 1 root root 817 1月 24 14:55 holiday.txt

-rw-r--r-- 1 root root 458 1月 25 19:52 create_passwd.sh

-rw-r--r-- 1 root root 134 12月 18 16:44 all.sh

-rw-r--r-- 1 root root 119 12月 18 16:56 99.sh

-rw-r--r-- 1 root root 96 12月 8 15:02 test.php

-rw-r--r-- 1 root root 38 12月 1 10:44 test.sh

-rw-r--r-- 1 root root 0 1月 24 00:00 tempfile

1) ls

[root@test23 script]# ls -Sh

test.conf count_pig.sh.bak two_points.sh create_passwd.sh 99.sh test.sh

count_pig.sh get_holiday.sh holiday.txt all.sh test.php tempfile

2) find

[root@test23 script]# find ./ -type f -printf '%s %p ' | sort -rn

2443 ./test.conf

1318 ./count_pig.sh.bak

1318 ./count_pig.sh

1180 ./get_holiday.sh

853 ./two_points.sh

817 ./holiday.txt

458 ./create_passwd.sh

134 ./all.sh

119 ./99.sh

96 ./test.php

38 ./test.sh

0 ./tempfile

3) du

[root@test23 script]# du -b * | sort -nr

2443 test.conf

1318 count_pig.sh.bak

1318 count_pig.sh

1180 get_holiday.sh

853 two_points.sh

817 holiday.txt

458 create_passwd.sh

134 all.sh

119 99.sh

96 test.php

38 test.sh

0 tempfile

原文地址:https://www.cnblogs.com/FengGeBlog/p/10415743.html