configure.conf
fruit-list="apple, pear, banana, watermelon"
Script
source /configure.conf
Then it shows error: /configure.conf: line 2: fruit-list=apple, pear, banana, watermelon: command not found
Can someone help me figure out why that happens?
I want the the fruit-list can be an list data type in shell script, which is same with
fruit-list="apple" "pear" "banana" "watermelon"
Please help me fix this issue.
CodePudding user response:
A (variable) name, at least with bash, may not contain a dash (-
):
name: A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore. Also referred to as an identifier. BASH(1)
You could use an underscore (_
) instead:
fruit_list="apple, pear, banana, watermelon"
And if you want fruit_list to be array it would be:
fruit_list=(apple pear banana watermelon)