When run by itself, whoami looks like this:
$ whoami
sbovisjb1
That should be sufficient to give you the clue on how to implement the test you seek:
if [ $(whoami) = "sbovisjb1" ]
then
execute the code, we're the right user
else
echo "You must be user 'joe' to run this script."
exit 0
fi
You can modify this to match the user or set of users you want to allow, or you can negate the logic to screen out bad userIDs immediately, like this:
if [ $(whoami) = "root" ]
then
echo "You cannot run this script as root."
exit 1
fi
original source:
http://www.askdavetaylor.com/how_can...k_user_id.html