I want to compare each user in the passwd file with his entry in the shadow file, and print out the whole line of the passwd file if the entry in the shadow file matches 999999. What is the easiest way in Perl to do this? Or I suppose I could awk the values out of one file and match in the other file? What is the best way of doing this?
awk -F":" 'FNR==NR&&$5=="99999"{user[$1];next}($1 in user)' /etc/shadow /etc/passwd
change FNR==NR&&$5=="99999"
to FNR==NR&&$5=="99999"&&$2!="!!"
if you want to exclude lines with "!!"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With