对于使用/bin/bash作为登录shell的系统用户,检查他们在/opt目录中拥有的子目录或文件数量,如果超过100个,则列出具体数值及对应的用户帐号.
具体实现:

#!/bin/bash
DIR="/etc"
LMT=100
validusers=`grep "/bin/bash" /etc/passwd|cut -d ":" -f 1`

for username in $validusers
do
 num=`find $DIR -user $username|wc -l`
 if [ $num -gt $LMT ];then
 echo "$username have $num files"
 fi
done