老李分享:《Linux Shell脚本攻略》 要点(七)上

老李分享:《Linux Shell脚本攻略》 要点(七)

1、显示给定文件夹下的文件的磁盘适用情况

[root@localhost program_test]# du -a -h ./
320K    ./output.tar
96K     ./reslt_yang.txt
4.0K    ./curr_dir.md5
4.0K    ./sed_data.txt

2、总计磁盘大小使用统计 -c

[root@localhost program_test]# du -h -c ./
48K     ./main
4.0K    ./abc
16K     ./dd_test
544K    ./tar-file
404K    ./touch_more/test_unzip
984K    ./touch_more
2.9M    ./
2.9M    total

 

//只显示统计 -s

[root@localhost program_test]# du -s -h ./
2.9M    ./

 

3、按文件大小排序

[root@localhost program_test]# du -ak ./ | sort -nrk 1 | head -n 5
2876    ./
984     ./touch_more
544     ./tar-file
404     ./touch_more/test_unzip
320     ./tar-file/output.tar

 

//只比较文件最大的前三位.

[root@localhost program_test]# find ./ -type f -exec du -k {} \; | sort -nrk 1 | head -n 3
320     ./tar-file/output.tar
320     ./output.tar
212     ./11.txt


你可能感兴趣的:(软件测试开发)