I have two lists of strings (with whitespace in each string), and want to read them one by one. The length of the strings are the same, so I get the length of one of them, via "${!argument[@]}"
, and try to read the elements of the lists. But it fails:
arguments="--a 100 --b 200" "--a 100 --b 200 --c"
settings="without_c" "with_c"
for index in "${!argument[@]}"
do
setting=${setting[$index]}
argument=${argument[$index]}
done
Gives the following error:
alp@ubuntu:~$ sh toy.sh
toy.sh: 1: toy.sh: --a 100 --b 200 --c: not found
toy.sh: 2: toy.sh: with_c: not found
toy.sh: 3: toy.sh: Bad substitution