I have two array bash, I want to ar array string to the end of name array.
array=(a b c)
name=(toto_ tata_)
result :
toto_a
toto_b
toto_c
tata_a
tata_b
tata_c
I try those command :
for i in "${name[@]}"
do
arra=( "${i/%/$array[@]}" )
done
printf '%s\n' "${arra[@]}"
>Solution :
I’d recommend using a second for:
array=(a b c)
name=(toto_ tata_)
arra=()
for i in "${name[@]}"; do
for j in "${array[@]}"; do
arra+=("$i$j")
done
done
printf '%s\n' "${arra[@]}"
Will produce:
toto_a
toto_b
toto_c
tata_a
tata_b
tata_c