Hi all.
I'm trying to finish a bash script with the following elements:
ARRAY[0]="blah $ITEM blah blah"
ARRAY[1]="blah blah $ITEM blah bluh"
#ARRAY[n]="...."
# ...the ARRAY elements represent a variable but defined
# syntax and they're all hard-coded in the script.
#(...)
ITEMS='1.0 2.3 -4.0'
#ITEMS=' .... '
# ...the ITEMS 'vector' comes from the command line
(...)
ARRAY[@] and ITEMS should have to get finally combined into NEWARRAY as detailed:
NEWARRAY[0]=blah 1.0 blah blah"
#(as ARRAY[0], but substituted with 1st item)
NEWARRAY[1]="blah 2.3 blah blah"
#(as ARRAY[0], but substituted with 2nd item)
NEWARRAY[2]="blah -4.0 blah blah"
#(as ARRAY[0], but substituted with 3rd item)
#-------------------
NEWARRAY[3]="blah blah 1.0 blah bluh"
NEWARRAY[4]="blah blah 2.3 blah bluh"
NEWARRAY[5]="blah blah -4.0 blah bluh"
# (as ARRAY[1], but substituted)
# (...)
I think that the combination issue is not a mayor problem as it could be (naively?) resolved with 2 loops:
c0=0; while [ $c0 -lt ${#ARRAY[@]} ]; do
for elem in $ITEM; do
#....???....???....
done
let "c0+=1"
done
Nevertheless the main problem to me is to get the $ITEMS values correctly referenced (if possible) within NEWARRAY during execution time. Anyway, I'm not sure if the whole stuff is well set...
Any help will be (desperately) welcome...
Y.