About Me

My photo
I know the last digit of PI

Thursday, June 07, 2018

Generate random password with bash script

This is a utility script that generate random password
#!/bin/bash

size=10

if [[ "$1" == "-h" || "$1" == "--help" ]]; then
  echo "randpw [size]"
  exit 0
elif [[ "$1" != "" ]]; then
  size="$1"
fi

cat /dev/urandom | env LC_CTYPE=C tr -dc '!@#.1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM' | head -c$size
echo ""

No comments: