Random Password Generator

by Kyle on · Posted in

#!/bin/bash
w="$1"
 
[[ -n "$w" ]] || w=12
if [[ $w -lt 8 ]]; then
    echo "A password of length $w would be too weak."
    exit 1
fi
passwd=$( cat /dev/urandom | tr -dc "a-zA-Z0-9_\?\$\#\." | fold -w $w | head -1 )
echo "${passwd}"

Save. Share. Submit.

Related Snips

Hide Sidebar