标签:shell
写一个脚本:要求如下:
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.
本文出自 “10484588” 博客,请务必保留此出处http://10494588.blog.51cto.com/10484588/1725934
标签:shell
原文地址:http://10494588.blog.51cto.com/10484588/1725934