要求:

1.设定变量FILE的值为/etc/passwd

2.依次向/etc/passwd中的每个用户问好,并且说出对方的ID是什么。

 举例:Hello,root,your UID is 0.

3.统计一个有多少个用户

#!/bin/bash 
#File: hello_user.sh
#Date: 2016-01-11
file="/etc/passwd"     //将文件赋值给变量
lines=`wc -l $file | cut -d ' ' -f 1`     //统计行数
for i in `seq 1 $lines`     //将i做循环
do
        uid=`sed -n "$i"p $file | awk -F : '{print $3}'`     //取出uid
        user=`sed -n "$i"p $file | awk -F : '{print $1}'`    //取出user
        echo "Hello, $user, your UID is $uid."
done
echo "There are $num users!"     //统计用户