zunxiongchen
2020-09-03 11:06:32 +08:00
试下这个吧
#!/bin/bash
export LANG="en_US.UTF-8"
USER=$(grep "/bin/bash" /etc/passwd | awk -F ":" '{print $1}')
echo "Username:PasswordExpires:LastPasswordChangeDate"
for TIME in $USER
do
echo -e "$TIME:\c"
PX=`chage -l $TIME | grep -w "Password expires" | awk -F ":" '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'`
echo -e "$PX:\c"
chage -l $TIME | grep -w "Last password change" | awk -F ":" '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
done