Skip to content

Commit ed62e36

Browse files
committed
added generate-random.sh
1 parent 1ece339 commit ed62e36

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

generate-random.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
LENGTH=25
5+
if [ ! -z "$1" ] && [ $1 -gt 1 ]; then
6+
LENGTH=$1
7+
fi
8+
9+
# inspired by https://www.baeldung.com/linux/generate-random-string-using-random
10+
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $LENGT | head -n 1

0 commit comments

Comments
 (0)