Working on a script which detects the current logged in userID, tests for UniqueID > 1000.
Problem: my user accounts include white space in their "user name" causing the script to fail.
Could anyone take a look and advise where I am going wrong here please!!
Thank You!
#!/bin/bash
loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'
accountType=dscl . -read /Users/$loggedInUser 2> /dev/null | grep UniqueID | cut -c 11-
if [[ "$accountType" -gt "1000" ]]; then
echo "demoting mobile account: $loggedInUser"
echo "UniqueID:$accountType"
/usr/sbin/dseditgroup -o edit -d "$loggedInUser" -t user admin
else
echo "Must be local admin account: $loggedInUser"
fi
exit 0
