Created
September 29, 2021 08:07
-
-
Save leiless/ec62fa42aa63db8aa7e9f2f69686ec5c to your computer and use it in GitHub Desktop.
Linux shell - how to generate random MAC address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eufo pipefail | |
#set -x | |
tr -dc a-f0-9 < /dev/urandom | head -c 12 | sed -r 's/(..)/\1:/g;s/:$//1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output
NOTE
You need to turn off
pipefail
when assign result oftr -dc a-f0-9 < /dev/urandom | head -c 12 | sed -r 's/(..)/\1:/g;s/:$//1'
into a variable.