统计所有用户占用磁盘空间的bash脚本
时间:2006-04-18 来源:icymoon
#!/bin/bash
ALL_USR_DIR=$(cat /etc/passwd | \
awk -F: 'BEGIN{ORS="\n"}{if (($7 != "/bin/nologin")&&($7 != "/sbin/nologin")){print $1 ":" $6 }}')
for USR in $ALL_USR_DIR;
do
echo $USR | awk -F: '{print $1}'
USR_DIR=`echo $USR | awk -F: '{print $2}'`
du -hs $USR_DIR done
ALL_USR_DIR=$(cat /etc/passwd | \
awk -F: 'BEGIN{ORS="\n"}{if (($7 != "/bin/nologin")&&($7 != "/sbin/nologin")){print $1 ":" $6 }}')
for USR in $ALL_USR_DIR;
do
echo $USR | awk -F: '{print $1}'
USR_DIR=`echo $USR | awk -F: '{print $2}'`
du -hs $USR_DIR done
相关阅读 更多 +