Coredump
Work, play, and everything in-between [feed]

Generate random strings

(Another “piecemeal” post. Yes, I know: I should write more often.)

I cycle through one-off passwords (of varying lengths). To generate these, I use the following shell script:


#!/bin/bash
 
usage() {
  echo "Usage: `basename $0` [length]"
}
 
[ $# -gt 1 ] && usage && exit 65
 
[ $# -eq 0 ] && len=8 || len=$1
 
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n $len | tr -d '\n'; echo

To use:

$ ./genrand.sh 16
tFJNxyZk4EYaJiuz

And, no, that’s not my password. Or is it?

Read more:


No Comments Yet


Be the first to comment!

Leave a comment


« »