Hi,
I am new script programming, I have written a script shown velow to read username and passwd from /etc/security/passwd, i am able to read username, but unable to grep lastupdate. please look into the code and suggest if any changes need.
#!/bin/ksh
USERNAME=""
fname=/usr/bin/lastupdate
ftemp=./temp
cat /etc/security/passwd | \
while read LINE
do
echo "$LINE" > fstring
USERWORDCNT=`grep ":" fstring | wc -w`
if [ $USERWORDCNT = 1 ]
then
USERNAME=$LINE
fi
UPDATEWORDCNT=`grep "lastupdate" fstring | wc -w`
if [ $UPDATEWORDCNT = 1 ]
then
UPDATE=`cat fstring | cut -d= -f2`
echo "$UPDATE"
STRING=$USERNAME$UPDATE
echo $STRING >> $fname
USERNAME=""
UPDATE=""
fi
done
chmod 666 $fname
Note: The output of programme should write username and lastupdate values ony to another new file in this format as shown below:
smith:12445
grith:34455