Skip to content

Instantly share code, notes, and snippets.

@selbyk
Last active June 8, 2016 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selbyk/b34803d6d20d0980a63070aa77e87a58 to your computer and use it in GitHub Desktop.
Save selbyk/b34803d6d20d0980a63070aa77e87a58 to your computer and use it in GitHub Desktop.
Generate random hex
#!/bin/bash
length=12
if [[ $1 =~ ^[0-9]+$ ]]; then
length=$1
fi
cat /dev/urandom | tr -dc 'a-fA-F0-9' | fold -w $length | head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment