Stack Overflow
has a space so it's being treated as two different variables when assigned to the array. In BASH
and even other shells like KSH
, etc, variable names cannot have spaces in them so a variable like Stack Overflow
wouldn't work even if it were surrounded with single or double quotes.
You can see this with the following commands:
export Stack Overflow=name echo $Stack Overflow
The output will be Overflow
as the argument for echo
is, in effect, $Stack, which hasn't been declared or assigned a value, and the word Overflow
.
echo $Overflow
That will output name
as the export
command assigned that value to the variable Stack
with Overflow=name
.
If you try either of these:
export "Stack Overflow'=name export 'Stack Overflow'=name
You'll get the error -bash: export: Stack Overflow=name': not a valid identifier
or -bash: export: Stack Overflow=name': not a valid identifier
.
One thing that you can do instead is to place underscores between the two strings:
export Stack_Overlow=name
That way, echo $Stack_Overflow
will output name
. That's going to require you to do more work because what you have in the CSV file contains spaces.