This question already has an answer here:
- Quoted vs unquoted string expansion 2 answers
In bash, we can read an file into an array, so that each line in the file becomes an element of the array.
$ arr=( $(cat myfile) )
I was wonder how
cat works so that it allows reading a file line as an array element? Does
cat separate the file content into lines?
cat not just read all the content of the file at once, without separating it into lines, so that
arr has just one single element, which is the entire content of the file? Thanks.