【shell】找到系统中最大的文件

来源:互联网 发布:mac windows分区减小 编辑:程序博客网 时间:2024/05/16 18:58
找到系统中最大的文件

1. 最大的文件夹
du / | sort -rn | head 
( it will certainly cost you a large amount of time if your filesystem is big) 
the options of "sort" are "r" and "n" not "m" 
it will help you to find out the ten larget files in / 
of course you can replace "/" with any directories you like! 

2.最大的文件
du -a | sort -rn | head 
    du -a write counts for all files, not just directories

3.
#!/bin/bash
path=/tmp/test/
file=`find $path -type f -exec stat -c "%s %n" {} \;|sort -nr|head -3 | awk -F ' ' '{print $2}'`
rm -f $file
0 0
原创粉丝点击