I have need to know how to use for loop with multiple variable.
Basically lets take for example /etc/passwd file has following entries
The above cat command will basically first greps the real users that have email addresses then converts ':' to '+' then using cut to extract the userid and email addresses using the '+' as a delimiter to produce the below output
Thanks for your replies. Well your method works but I need to do some more further manipulation. I'm trying to rewrite the solaris password aging script "pwage" for hpux Trusted systems. I already figured out the calculation part I just need to find a way for the script to be able to reply to the user that's why I'm trying to use a for loop.
Not sure if this is what you're looking for, but it's unnecessary to use a temporary file for the userid.
You could do something like this:
MAXAGE=90
while IFS=: read uid dummy
do
for j in `find /tcb -name "$uid" -exec ls -1 {} \;`
do
LASTPWCHG=`awk -F: '/u_succhg/{print $3}' "$j"`
DAYSEC=86400
DAWNOFTIME=`/usr/contrib/bin/perl -e 'print int(time)'`
SECSAGO=`echo "$DAWNOFTIME - $LASTPWCHG" | bc`
DAYSAGO=`echo "$SECSAGO/$DAYSEC" | bc`
LEFTDAYS=`echo "$MAXAGE - $DAYSAGO" | bc`
if [ "$LEFTDAYS" -le 7 ]
then
# show a reminder and send to user email address.... etc
fi
done
done < /etc/passwd