Use the mapfile
command:
mapfile -t myArray < file.txt
The error is using for
— the idiomatic way to loop over lines of a file is:
while IFS= read -r line; do echo ">>$line<<"; done < file.txt
See BashFAQ/005 for more details.
Use the mapfile
command:
mapfile -t myArray < file.txt
The error is using for
— the idiomatic way to loop over lines of a file is:
while IFS= read -r line; do echo ">>$line<<"; done < file.txt
See BashFAQ/005 for more details.