Skip to main content
added 4 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

I have an array and i am looping through the variable to run other commands. The last thing i need to do with the array value before going onto the next one is create a variable with the array value as the name and assign a string that includes other variables inside.

Currently my code looks like this:

for i in ${array[@]} do
    some commands
command
    $i_value="my string including other variables ${other_variable}"
done
echo  $i_value

when i run this i get the following error and i dont know why its looking for a file and not creating a variable with the array value (which its getting):

line 5: *value*_value=my string including other variables *other_variable*: no such file or directory.

I have an array and i am looping through the variable to run other commands. The last thing i need to do with the array value before going onto the next one is create a variable with the array value as the name and assign a string that includes other variables inside.

Currently my code looks like this:

for i in ${array[@]} do
some commands

$i_value="my string including other variables ${other_variable}"
done
echo  $i_value

when i run this i get the following error and i dont know why its looking for a file and not creating a variable with the array value (which its getting):

line 5: *value*_value=my string including other variables *other_variable*: no such file or directory.

I have an array and i am looping through the variable to run other commands. The last thing i need to do with the array value before going onto the next one is create a variable with the array value as the name and assign a string that includes other variables inside.

Currently my code looks like this:

for i in ${array[@]} do
    some command
    $i_value="my string including other variables ${other_variable}"
done
echo $i_value

when i run this i get the following error and i dont know why its looking for a file and not creating a variable with the array value (which its getting):

line 5: *value*_value=my string including other variables *other_variable*: no such file or directory.
Source Link
a.smith
  • 745
  • 4
  • 15
  • 30

bash - Is it possible to create variable that has a variable as its title and has a string value with other variables in?

I have an array and i am looping through the variable to run other commands. The last thing i need to do with the array value before going onto the next one is create a variable with the array value as the name and assign a string that includes other variables inside.

Currently my code looks like this:

for i in ${array[@]} do
some commands

$i_value="my string including other variables ${other_variable}"
done
echo  $i_value

when i run this i get the following error and i dont know why its looking for a file and not creating a variable with the array value (which its getting):

line 5: *value*_value=my string including other variables *other_variable*: no such file or directory.