awk '/user/ {print $1 }' /etc/userdomains | sed 's/://'the format of /etc/userdomains isdomain.tld: userotherdomain.tld: otheruser
How could I simplify this command to only use awk?
command line;shell;sed;text processing;awk
The easiest way is to set the field separator to :awk -F: '$2~/user/{print $1}' /etc/userdomainsAnd if you want to check for exact username, awk -F[ \t]*:[ \t]* '$2==user{print $1}' /etc/userdomains