Get the full name of a user via AppleScript or command line?

How can I get the full name of a user in Mac OS X via AppleScript or the command line?

Any ideas without using UI Scripting?

This is an adaptation of a chunk of code found here:

do shell script "finger `whoami` | grep Login | colrm 1 46""

You can also use a scripting addition called “MacPack Toolbox.” Honestly I can never remember all those CLI commands and such for something as simple as this.

Available here (free):

jj and ExitToShell, thanks for the hints.
I found also a third way using the system_profiler from the command line.

Finally I have adapted jj’s solution with system attribute “USER” instead of the two back ticks commands.


Welcome, ExitToShell!
I just wrote an article about search/replace text and speed, and “MP Replace” was the winner in the exposed test. The stuff is in spanish, but here is anyway: