Quantcast
Channel: User Dennis Williamson - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 61

Answer by Dennis Williamson for Process /etc/passwd file to list all users whose home folder is in /home

$
0
0

Assuming e.txt is actually /etc/passwd, you should actually use getent passwd instead of parsing the file since user account information may be stored in multiple locations specified in /etc/nsswitch.conf such as LDAP.

getent passwd | awk -F ':' '$6 ~ "^/home"'

Note that the print statement is implied when the condition is true. That will print the whole line, though. This will print only the user name:

getent passwd | awk -F ':' '$6 ~ "^/home" {print $1}'

Viewing all articles
Browse latest Browse all 61


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>