如果要非常直观地按大到小显示个文件目录的大小,我们可以使用脚本来完成,对 du 后的信息进行处理后再按照要求输出,比如只输出大小在多少M以上的目录信息
这是很久以前的一个脚本,这几天正好有时间,就整理了下。
#!/usr/bin/perl
## filename: dfdir.pl ## script for getting file list of specified directory, ## then output them in order by size.
## Powered by Muddyboot, last modified: 2005-04-26 ## only accept one parameter
$basename=substr($0,rindex($0,'/')+1); sub usage(){ print"/nUsage: $basename DIRECTORY [MIN-SIZE]/n/n"; print"Get file list of DIRECTORY, then output them in order by size./n"; print"If MIN-SIZE is specified, only print those greater than MIN-SIZE./n"; print"MIN-SIZE is non-zero integer optionally followed by a k/K/m/M./n/n"; exit; }
sub print_err (){ die"/n/e[1;31m$_[0]/e[0;39m/n/n"; }