Bash - Run 'chage' Command Against Each User Account
The literal answer to your question:
#!/bin/bash
users=$(awk -F: '{ print $1}' /etc/passwd)
for value in $users
do
echo $value
chage -l $value
echo "....."
echo ""
done
should generate output in the form of
userA
Last Password Change: 1/2/34
Password Expires: 1/2/34
Password Inactive: 1/2/34
.....
userB
Last Password Change: 1/2/34
Password Expires: 1/2/34
Password Inactive: 1/2/34
.....
Note that the source of the information chage
displays is encoded in the fields of the /etc/shadow
file (expressed as the number of days since Jan 1, 1970) .
Parsing that file directly might be significantly more efficient than using chage
and/or other tools that convert those fields to human readable output and parsing that.