If you’re editing a Minecraft server to add an operator or set up a whitelist, and you’re not already an operator, you’ll need to convert your Minecraft user name into a UUID and edit the operators file, and for some versions the whitelist file as well. You can do this online, using mcuuid.net for example, but if you want to automate a server setup, here’s a short bash script to do the conversion on the command line. It does it by calling the Mojang API and then adding hyphens in the right places.
The script expects a Minecraft user name as a command line parameter, and needs to run in the bash shell (as the adding hyphens part uses some bash specific syntax).
You can pick up the script from github here: https://raw.githubusercontent.com/gbowerman/azure-minecraft/master/scripts/mineuuid.sh
Also including it below for reference..
# Script to convert a Minecraft username to a UUID that you can use in operator/whitelist files etc.
# $1 = Minecraft user name
if [[ ! $# -eq 1 ]] ; then
echo 'Error: Expected one argument: Minecraft user name.'
mojang_output="`wget -qO- $UUID_URL`"