写一个脚本:要求以下:
1:依次向/etc/passwd目录中的每个用户问好,并指出其UID号!(eg:Hello root,your uid is 0)
2:统计这个脚本共有多少个帐户?bash
#!/bin/bashide
name=`cat /etc/passwd |awk -F: '{print $1}'`ui
for u in $name
spa
doorm
i=`id $u |awk -F'=' '{print $2}' |awk -F'(' '{print $1}'`it
uid_num=`grep $u:x /etc/passwd |awk -F: '{print $3}'`class
if [ $i == $uid_num ]awk
thengrep
echo "Hello $u, your uid is $i !"im
else
echo "Wrong!!!"
fi
done
y=`cat /etc/passwd |wc -l`
echo "There are $y users.