Using NIS-ypmatch, ypcat, Lname, Gname to get username/key

Hello,

We can get the full info by typing:

ypmatch username passwd

aaaa : yyyy: ... ... : LastName Gname : ... ...

However, I'd like to know how could we get the username based on LastName and Given name please?

Thanks a lot,
ly

I don't think you can - if you list the keys for that map, it will be the first entry of each line (the username).

You can ypcat the file (ypcat passwd) and grep for the Last/Given Name and then print the first field (username) with awk.

do

ypmatch username passwd | awk -F: '{print $5}'

Thanks a lot!

Combining and getting the command:

ypcat passwd | grep "Last name First Name" | awk -F : '{print $5}'

is exact what I am looking for.