3 ms·
The awk version looks idiomatic to me. Except that I will take the FS out: awk -F: '$6=="/sbin/nologin" {print $1}' /etc/passwd
by irahul 15y ago
The awk version looks idiomatic to me. Except that I will take the FS out:
awk -F: '$6=="/sbin/nologin" {print $1}' /etc/passwd
- d0mine 15y agoThere might be off by one error. On my system the following works: awk -F: '$7=="/usr/sbin/nologin" {print $1}' /etc/passwd Or awk -F: '$7 ~ /bin\/nologin$/ {print $1}' /etc/passwd
- irahul 15y agoYes, indeed it should be $7 instead of $6. I didn't run it when I posted the comment. I just copied it from the article.