Skip to content

Instantly share code, notes, and snippets.

@untoreh
Last active April 19, 2018 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save untoreh/f094bb55d51358c3ffd4acb85488dad4 to your computer and use it in GitHub Desktop.
Save untoreh/f094bb55d51358c3ffd4acb85488dad4 to your computer and use it in GitHub Desktop.
forking is evil

Generate a random string with just bash

Adding options to add newlines, choose lowercase or uppercase or both is trivial

rand_string() {
    local c=0
    while [ $c -lt $1 ]; do
        printf "\x$(printf '%x' $((97+RANDOM%25)))"
        c=$((c+1))
    done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment