1:依次向/etc/passwd目录中的每一个用户问好,并指出其UID号!(eg:HELLO,root,your uid is 0)
2:统计这个脚本共有多少个账户?
#!/bin/bash
a="/etc/passwd"
b="/root/b"
if awk -F: '{print "hello," $1"," " your uid is " $3 }' $a > $b
then
cat $b
awk '{print $2}' $b |wc -l
fi
[root@slave1 ~]# sh aaa
hello,root, your uid is 0
hello,bin, your uid is 1
hello,daemon, your uid is 2
hello,adm, your uid is 3
hello,lp, your uid is 4
hello,sync, your uid is 5
hello,shutdown, your uid is 6
hello,halt, your uid is 7
hello,mail, your uid is 8
hello,uucp, your uid is 10
hello,operator, your uid is 11
hello,games, your uid is 12
hello,gopher, your uid is 13
hello,ftp, your uid is 14
hello,nobody, your uid is 99
hello,vcsa, your uid is 69
hello,saslauth, your uid is 499
hello,postfix, your uid is 89
hello,sshd, your uid is 74
hello,mysql, your uid is 500
hello,php-fpm, your uid is 501
hello,ntp, your uid is 38
hello,named, your uid is 25
hello,zabbix, your uid is 498
hello,memcached, your uid is 497
hello,redis, your uid is 503
hello,mailnull, your uid is 47
hello,smmsp, your uid is 51
28