I have an array of paths to files which each have several lines of text. I'd like to produce an array that is populated with the first line of each file processed like so:
# this.txt first line is [Test this]
# another.txt first line is [Test another]
paths=(
./this/path/this.txt
./another/path/another.txt
)
for i in ${paths[@]}; do
read -r line < $i
lines+=$line
done
At most I've only gotten one value in my array. I can't seem to get the array I'm looking for out of the for loop. I've tried many variations and having a hard time figuring out where I'm going wrong.