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}'