首页 > IT职业 > IT生活 > 列出size大于某特定值的所有子目录
下面的脚本根据你给定的目录和阈值,会遍历所有子目录,并列出大于阈值的所有子目录名称和大小。
注意如何在awk中引用shell变量。
[@more@]dasomg01(215)% cat big_dir.sh
#!/bin/sh
if [ $# -ne "2" ]
then
pgm=`basename $0`
echo "Usage: $pgm
echo " target_dir => the directory to be checked"
echo " bytes => the threshold"
exit 1
fi
cd $1
threshold=$2
for i in `ls -l|grep '^d'|awk '{print $9}'`
do
du $i | awk '{if ($1>'"$threshold"') {print $1,$2}}'
done
==执行结果==
dasomg01(216)% sh big_dir.sh $ORACLE_HOME 1000000
8010934 network/trace
8094308 network
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/207/viewspace-1031350/ ,如需转载,请注明出处,否则将追究法律责任。