How can I get a logged user's username without the domain? I'm trying to write a script to automate a task that involves the logged user's username.  The problem is the username is coming up as domain/username and I just need the username.

LOGGEDUSER=$(stat -f "%S" /dev/console);


Any way to output the result and remove part of it?  This currently outputs domain/username I need to remove the domain/.
Local Domain

See Get current users username in bash? for a range of approaches:

logname


or

echo $USER


or

whoami


or

id -u -n


Network Domain

If you are on an (Active Directory) network domain, you can use

echo ${USER#*\\}


or

u=$(logname)
echo ${u#\\}


to just get the user name part.