I have an array setup:
target_array=(
"item1 -a100 -b250 -caaa"
"item2 -a110 -cbbb -d1sa"
"item3 -d2sa -exxx -fyyy"
)
I then iterate over the array and perform various actions:
for target_item in "${target_array[@]}"; do
#Do Stuff Here
#and create new items
x=111
y=222
z=333
done
Inside the loop I get new variables and need to add them to the array, so I would end up with something like:
target_array=(
"item1 -a100 -b250 -caaa -x111 -y222 -z333"
"item2 -a110 -cbbb -d1sa -x112 -y223 -z334"
"item3 -d2sa -exxx -fyyy -x113 -y224 -z335"
)
But how can I add these items to the array? Should I be adding them to the existing array, or creating a new array?
I'm trying to port a script from powershell
where I would use an 'object' that contained items (item1) and properties (-a) with values (100). But couldn't see a Linux equivalent so an array seemed to be the next best thing.