The implementation of
uuidgen on Linux returns all lowercase letters by
default. The implementation of
uuidgen on macOS returns all uppercase letters
by default. This triggers the hell out of me, by default.
Usually when I approach consistency between macOS and Linux, both of which I use
daily, I will bend Linux to Apple’s will, since that tends to be the path of
In this scenario though, I don’t want to have uppercase UUIDs at all, so I’ve
willed Apple more in the direction of Linux.
Armed with my trusty
tr command, to translate characters, I was able to pipe
the output of
uuidgen to it and swap the
letters. Said command
looks like this:
uuidgen | tr A-Z a-z
Works like a champ, but let’s not stop there. Universally unique identifiers
(UUIDs) only contain the first six letters of the alphabet, A through F, so we
can improve things a bit:
uuidgen | tr A-F a-f
With that bit of golfing out of the way, we can take this command and alias like
alias uuidgen='uuidgen | tr A-F a-f'
Better still, only alias it when we’re on a macOS machine:
if [[ `uname` == Darwin ]] then alias uuidgen='uuidgen | tr A-F a-f' fi
The reason I aliased it back over
uuidgen instead of opting for the shorter
uuid is because I don’t like aliasing commands just to make them shorter, with
the exception of
Just my personal preference, so feel free to name the alias as you see fit!
Just for grins, here’s the more verbose, but same result, that GitHub Copilot
suggested to me:
alias uuidgen='uuidgen | tr "[:upper:]" "[:lower:]"'