I have one system that I would like to do a little clean up, so I would like to get all user accounts and last date they accessed they mail. It is a Debian system.
So far I got to this:
cut -d: -f1 /etc/passwd | xargs -n1 finger | grep "Mail last read"
But I dont know how to write that username in front of Mail last read Sun Aug 12 03:06 2012 (CEST)
Thank you
edit: this is sample finger output:
/bla# finger xxxxx
Login: xxxxx Name: xxxxx xxxxx
Directory: /home/xxxxx Shell: /bin/true
Never logged in.
Mail last read Sun Aug 12 03:17 2012 (CEST)
No Plan.
Using the -B option:
assuming that the line containing “Login: Name: ” appears 3 lines before the mail status in the output of finger. The
awkcommand prints the 2nd field of the first line of the output from grep, as well as the line containing the mail status.