Created
March 5, 2019 11:32
-
-
Save jetstreamin/60e4a5991be0bfe20d03df21ae496ff0 to your computer and use it in GitHub Desktop.
bash: read file to array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snagged from https://stackoverflow.com/a/30988704 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment