I have 10 text files and I want to paste
each file with its pair, such that I have 5 total files.
I tried the following:
for i in 4_1 5_
You can use an associative array:
animals=(dog cat mouse)
declare -A size=(
[dog]=big
[cat]=medium
[mouse]=small
)
declare -A sound=(
[dog]=barks
[cat]=purrs
[mouse]=cheeps
)
for animal in "${animals[@]}"; do
echo "$animal is ${size[$animal]} and it ${sound[$animal]}"
done
This allows you traversing pairs, triples, etc. Credits: the original idea is taken from @CharlesDuffy-s answer.