Retrieve current user's full name, Mac OS X
Alec Jacobson
December 05, 2009
osascript
is a command that allows you to execute applescript via the command line and in script. Here's a short command that retrieves the current users full name.
osascript -e "long user name of (system info)"
Anyone know how to do this in pure bash/unix tools?
Update: Gmail Notifier corrupted my osascript so now I have to send the bogus errors to /dev/null like this:
osascript -e "long user name of (system info)" 2>/dev/null
Update:
Here's another way I found the long user name:
system_profiler | grep "User Name:" | sed "s/^ User Name: \([^(]*\) (.*/\1/g"
Update: On linux consider using this:
getent passwd $USER | cut -d ":" -f 5