Skip to content

Instantly share code, notes, and snippets.

@allenmichael
Created January 28, 2022 16:27
Show Gist options
  • Save allenmichael/95b921edbfcd4024147a64ce7266de0a to your computer and use it in GitHub Desktop.
Save allenmichael/95b921edbfcd4024147a64ce7266de0a to your computer and use it in GitHub Desktop.
#!/bin/sh
random_string() {
STR_LENGTH=${1:-20}
INCLUDE_SYMBOLS=${2:-0}
FILTER='A-Za-z0-9'
SYMBOLS=${3:-'!@#%^&*'}
if [ $INCLUDE_SYMBOLS -eq 0 ]; then
FILTER="$FILTER$SYMBOLS"
fi
echo $FILTER
START=$(LC_ALL=C tr -dc $FILTER </dev/random | head -c ${1:-$STR_LENGTH})
echo $START
}
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment