On surface, the goal is to run chage ...
on any user with uid > 1000, excluding two predefined users (person1, person2). Minor fix to the loop should address the problem.
Two minor issues are fixed: the awk is using ':' as field separator, and the bash loop iterate over a simple variable (instead of array). Solution integrate the user filter into awk scripts, eliminating the separate grep
:
user_list=`awk -F: '$3 > 1000 && $1 !~ "$(person1|person2)$" { print $1 }' < /etc/password`
for x in $user_list ; do
chage -M 60 "$x"
done
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…