Can I improve this AWK/SED script that lists all users in columns?
Hi there,
Building a user management script (add/delete/lock/unlock/list/etc users) and building my line to pull all usernames from /etc/passwd and display ONLY user names (no machine names, no special names) and I am pretty close. I'd like to improve it though. Here's the line currently: Code:
awk -F":" '$7 ~ /\/bin\/bash/ {print $1}' /etc/passwd | sed '/\$/d' | sort | uniq -u | column Code:
user1 user2 user3 user4 |
Quote:
Kevin Barry edit: Code:
grep -f /etc/shells /etc/passwd | cut -d: -f1 | sort | column |
Quote:
Will uniq -u ignore lines that have duplicates (that is, if a line has a duplicate, remove BOTH lines)? My intention is to list, with no duplications, every user on the system (minus machine names, which for us contain a "$" sign). AFAIK all our users use Bash, but if it would help make the script more portable I can use /etc/shells instead. |
Quote:
Quote:
Kevin Barry |
Perfect, thanks for explaining.
I've updated the line to: Code:
grep -f /etc/shells /etc/passwd | cut -d: -f1 | sed '/\$/d' | sort | column |
All times are GMT -5. The time now is 06:16 PM. |