while循环控制
检索普通用户,显示账户将要过期的用户 #!/bin/bash //统计普通用户 if [ -s /root/user.txt ] then echo "">/root/user.txt fi while read LINE;do A=`echo $LINE|cut -d: -f3` if [ $A -ge 500 ] then echo "the user `echo $LINE |cut -d: -f1` is normal user" echo $LINE |cut -d: -f1 >>/root/user.txt //统计过期用户 fi done</etc/passwd C=`date +%s/24/60/60` while read LINE;do //至今距离1970年的期限(天) B=`grep "^$LINE\>" /etc/shadow |cut -d: -f5` if [ $(($B-$C)) -le 10 ] then echo "the user $LINE is expire" fi done </root/user.txt --------------- #let E=`date +%s24/60/60` //计算现在的时间 #chage user1 //更改密码的有效时间 #A=`ll lwy` #echo ${A%%r*} //从右到左截取到最后一个r