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}
done
Output is:
aa
...
99999
I want to keep it like that. First all combinations of 2 chars, then all combinations of 3 chars, etc.