Skip to content

Commit

Permalink
added generate-random.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
br-cpvc committed May 3, 2024
1 parent 1ece339 commit ed62e36
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions generate-random.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

LENGTH=25
if [ ! -z "$1" ] && [ $1 -gt 1 ]; then
LENGTH=$1
fi

# inspired by https://www.baeldung.com/linux/generate-random-string-using-random
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $LENGT | head -n 1

0 comments on commit ed62e36

Please sign in to comment.