shell---practice1
#!/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!" //统计用户
页:
[1]