I'm sharing this in case anybody needs it. Modified from the original solaris pwage script. This modified hpux script will check /etc/password file on hpux trusted systems search /tcb and grep the required u_succhg field. Calculate days to expiry and notify users via email.
/etc/passwd file needs to have a "+email@domain.com" in the description field. You can use '+' or any other symbol but not sure if you can use another ':'
The normal secondary delimiter in the /etc/passwd comments field is a comma. Don't try a colon - it will corrupt the passwd file. The "usermod" command should stop you creating an invalid passwd file.
This is a dodgy construct because it can give false matches in any field. In the simple case, consider usernames called "fred", "freda" and "alfred". One extreme case would be a username called "home".
A safer version in the style of your script:
grep \^${i}: /etc/passwd |
On many O/S the "for i in <open ended list>" construct will collapse when the command line becomes too long for the CLI.
Just for interest in non-trusted HP-UX you can get all the base information for this type of script from the command: