how to Print first 2 columns of passwd file

triapthisuresh
Posts: 133
Joined: Fri Aug 12, 2016 1:17 pm

how to Print first 2 columns of passwd file

Postby triapthisuresh » Fri Aug 12, 2016 7:06 pm

How to print first 2 columns of /etc/password file?

amit.g512
Posts: 81
Joined: Fri Aug 12, 2016 6:55 pm

Re: how to Print first 2 columns of passwd file

Postby amit.g512 » Fri Aug 12, 2016 7:09 pm

You can use AWK command to print columns of /etc/passwd file

# awk -F: '{ print $1; print $2 }' /etc/passwd

# awk -F: '{ print $1 " " $2}' /etc/passwd

# awk -F: '{ printf("%s %s %s\n", $1, $2}' /etc/passwd


Return to “Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest