清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/bash # # find big disk space users in various directories CHECK_DIRECTORIES="." #default directories to check DATE=`date '+%m%d%y'` #date for report file #exec > Disk_Space_$DATE.log parameters=`getopt sS "$@"` set -- $parameters #replace origin parameters for param in "$@" do case $param in -s) range=$param;; -S) range=$param;; -l) list=$param;; --) break;; esac done count=1 while [ -n "$1" ] do if [ -d "$1" ]; then echo "" echo The $1 Directory: du $range $1 2>/dev/null | sort -rn | sed -e '11,$D; =' | sed '{N; s/\n/ /}' | awk 'BEGIN{} { delimiter = 1024 Mb = int($2 / delimiter) if(Mb >= 1) { size = Mb"Mb" } else { size = $2"Kb" } Gb = int(num / (delimiter * delimiter)) if(Gb >= 1) { size = Gb"Gb" } printf $1 ":" "\t" size "\t" $3 "\n"} END{}' fi count=$[ $count + 1 ] shift done