Skip to content

Instantly share code, notes, and snippets.

@mhingston
Created February 18, 2018 19:49
Show Gist options
  • Save mhingston/3ab043bc562ac78a04ad61e7de9223b6 to your computer and use it in GitHub Desktop.
Save mhingston/3ab043bc562ac78a04ad61e7de9223b6 to your computer and use it in GitHub Desktop.
Generate a random password using /dev/urandom
#!/bin/bash
if [[ $1 =~ ^[0-9]+$ ]]
then
cat /dev/urandom | tr -dc '[:graph:]' | head -c $1; echo
else
cat /dev/urandom | tr -dc '[:graph:]' | head -c 20; echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment