写一个脚本:要求如下:
1:依次向/etc/passwd目录中的每一个用户问好,并指出其UID号!(eg:Hello root,your uid is 0)
2:统计这个脚本共有多少个账户?
#!/bin/bash
name=`cat /etc/passwd |awk -F: ‘{print $1}‘`
for u in $name
do
i=`id $u |awk -F‘=‘ ‘{print $2}‘ |awk -F‘(‘ ‘{print $1}‘`
uid_num=`grep $u:x /etc/passwd |awk -F: ‘{print $3}‘`
if [ $i == $uid_num ]
then
echo "Hello $u, your uid is $i !"
else
echo "Wrong!!!"
fi
done
y=`cat /etc/passwd |wc -l`
echo "There are $y users.
时间: 2024-11-06 03:53:37