du.sh directory

#!/bin/bash
# 读取一个目录
read -p "Please input check directory.." Dirc
dir=`ls $Dirc`
for i in $dir
do
   # 如果这个目录是否是根目录
    if [ $Dirc = '/' ]; then
        if [[ $i = "mnt" || $i = "lost+found" || $i = "proc" ]] ; then
            continue
        else
            du -sh /$i
        fi
    else
        if [[ $i = "lost+found" ]]; then
            continue
        else
            du -sh $Dirc/$i
        fi
    fi
done


你可能感兴趣的:(dircectory)