Awk and Bash: Print Linux/Unix User Accounts
There are ways how to do this:
To add filter in the result, you can
Hope this helps!
awk -F':' '{ print $1 "\t" $3 }' /etc/passwdThat would print the username and the UID. You can also add the sort command at the end like
awk -F':' '{ print $1 "\t" $3 }' /etc/passwd | sortand this will sort alphabetically.
To add filter in the result, you can
awk -F':' '$1 == "hachiko" { print $1 "\t" $3 }' /etc/passwd | sortwhere hachiko is a username you wanted to print with its UID.
Hope this helps!
Comments