How do I read username and lastupdate attribute values from /etc/security/passwd

Hi,

How do I read username and lastupdate attribute values from /etc/security/passwd file and write the obtained data to another file. The data in the new file should be in this format as shown:

avins:12345
root:45234
xyza:23423

Plese let me know this ASAP

Thanks,
Haroon

sed "s/^\([^:]*\):[^:]*:[^:]*:\([^:]*\).$/\1:\2/" /etc/security/passwd
Note: number of [^:]
in the middle of the pattern equals to number of columns separated by ':' you want to skip

Hi All,
As i asked you in my previous post, I want to read username and lastupdate only from /etc/security/passwd and write the same data to another file:
The data in /etc/security/passwd will be in this form for example:

smith:
password = MGURSj.F056Dj
lastupdate = 623078865
flags = ADMIN,NOCHECK

From this I want username i.e smith and value in lastupdate to be written to another file test.

Note: I should be able to write information of all users to test file in this format
smith:623078865

I hope this will be appropriate:

#!/bin/sh

cat /etc/security/passwd | sed -n '
/^.*:\s*$/ h
/^\slastupdate/ {
s/^\s*lastupdate\s*=\s
//
H
g
s/\n//
p
}
' > test