1、find可以实现对指定文件大小的查找
root@PC1:/home/test2# ls b.ped outcome.map outcome.ped root@PC1:/home/test2# ll -h total 1.4G -rw-r--r-- 1 root root 1.3G 12月 22 22:30 b.ped -rw-r--r-- 1 root root 1.3M 12月 22 22:28 outcome.map -rw-r--r-- 1 root root 158M 12月 22 22:29 outcome.ped root@PC1:/home/test2# find ./ -type f -size +500M ## -type f 指定对文件进行查找, -size +500M 指定查找大于500M的 ./b.ped
root@PC1:/home/test2# ll -h total 1.4G -rw-r--r-- 1 root root 1.3G 12月 22 22:30 b.ped -rw-r--r-- 1 root root 1.3M 12月 22 22:28 outcome.map -rw-r--r-- 1 root root 158M 12月 22 22:29 outcome.ped root@PC1:/home/test2# find ./ -type f -size -300M ## 查找小于300M的文件 ./outcome.map ./outcome.ped
2、ls -S直接实现对文件大小的排序
root@PC1:/home/test2# ls b.ped outcome.map outcome.ped root@PC1:/home/test2# ll -h total 1.4G -rw-r--r-- 1 root root 1.3G 12月 22 22:30 b.ped -rw-r--r-- 1 root root 1.3M 12月 22 22:28 outcome.map -rw-r--r-- 1 root root 158M 12月 22 22:29 outcome.ped root@PC1:/home/test2# ls -S | sed 's/\t/\n/g' b.ped outcome.ped outcome.map root@PC1:/home/test2# ls -S | sed 's/\t/\n/g' | xargs du -h ## ls -S直接实现文件从大到小的排序 1.3G b.ped 158M outcome.ped 1.3M outcome.map root@PC1:/home/test2# ls -S | sed 's/\t/\n/g' | xargs du -h | sort 1.3G b.ped 1.3M outcome.map 158M outcome.ped root@PC1:/home/test2# ls -S | sed 's/\t/\n/g' | xargs du -h | sort -h ## 实现从小到大排序 1.3M outcome.map 158M outcome.ped 1.3G b.ped
3、du命令实现排序
root@PC1:/home/test2# ls b.ped outcome.map outcome.ped root@PC1:/home/test2# du -ah ## 列举出每个文件的大小及总大小 1.3M ./outcome.map 1.3G ./b.ped 158M ./outcome.ped 1.4G . root@PC1:/home/test2# du -ah | sort -h ## 从小到大排序 1.3M ./outcome.map 158M ./outcome.ped 1.3G ./b.ped 1.4G . root@PC1:/home/test2# du -ah | sort -h | sed '$d' ## 从小到大排序并删除最后一行 1.3M ./outcome.map 158M ./outcome.ped 1.3G ./b.ped root@PC1:/home/test2# du -ah | sort -rh ## 从大到小排序 1.4G . 1.3G ./b.ped 158M ./outcome.ped 1.3M ./outcome.map root@PC1:/home/test2# du -ah | sort -rh | sed 1d ## 从大到小排序并删除第一行 1.3G ./b.ped 158M ./outcome.ped 1.3M ./outcome.map