I made this script which generates all combinations of lowercase letters and numbers and echoes them. It works, but I am wondering if there is a way to simplify the process of adding a new char instead of my current way of having to make a new function for every new character I want to add. Here's my script:declare -r LIST=$(echo {a..z} {0..9})function word_generation_2 {    for char1 in  ${LIST}; do        for char2 in  ${LIST}; do            echo ${char1}${char2}        done    done}function word_generation_3 {    for char1 in  ${LIST}; do        for char2 in  ${LIST}; do            for char3 in  ${LIST}; do                echo ${char1}${char2}${char3}            done        done    done}function word_generation_4 {    for char1 in  ${LIST}; do        for char2 in  ${LIST}; do            for char3 in  ${LIST}; do                for char4 in  ${LIST}; do                    echo ${char1}${char2}${char3}${char4}                done            done        done    done}function word_generation_5 {    for char1 in  ${LIST}; do        for char2 in  ${LIST}; do            for char3 in  ${LIST}; do                for char4 in  ${LIST}; do                    for char5 in  ${LIST}; do                         echo ${char1}${char2}${char3}${char4}${char5}                    done                done            done        done    done}for ((i = 2; i < 6; i++)); do    word_generation_${i}doneOutput is:aa...99999I want to keep it like that. First all combinations of 2 chars, then all combinations of 3 chars, etc.
Word generation with nested loops
shell script
In Bash or something that supports arrays, you could put the character set in an array and loop over the array again, prepending the characters again:chars=( {a,b,c} )doubles=()triplets=()for c in ${chars[@]} ; do     doubles+=( ${chars[@]/#/$c} )donefor c in ${chars[@]} ; do     triplets+=( ${doubles[@]/#/$c} )doneecho ${triplets[@]}that prints aaa aab aac ... ccc, and you can repeat as necessary for the longer ones, or turn it into a recursive function. (The ${var//} is a pattern substitution where # marks the start of the string. When it's applied to an array, it applies to all values of the array, one at a time.)