This is probably going to be marked as duplicate, but after reading several posts, I still can't make my bash script work.
I have a text file with multiple lines; each line has 1 string only. I want to import the content to a bash variable, such as each line is a separate element.
So, as an example, if MYVAR
is the mentioned variable, I want to be able to access any element by its position, e.g.:
for i in $(seq 0 2)
do
echo ${MYVAR[$i]}
done
The above is just an example; I do not need a for loop, that is why i have not used while read LINE
strategy.
I have tried several ways, but the file keeps being imported as 1 long string which includes the whole content. Hope my purpose is clear, I appreciate any help.