I want to get a user's real life name based to print during the login script.
I'm using currently the following command:
finger | grep $LOGNAME | head -1 | awk '{print $2 " " $3}'
Is there any better way? I did not see in finger
's man page that it has an argument to get only the real life name.
I'm using TCSH on a SunOs machine.
That's just the GECOS field from the password file, so you could get it directly from there if you wanted to:
If someone were using the GECOS field to store more than the full name, eg an office telephone number as well (as is permitted, but is no longer common), you'd need to run it through another cut to get only the "full name" portion of the field:
getent passwd $LOGNAME | awk -F ":" '{print $5}'
should be easier. The real name is called 'gecos'