Skip to content

Instantly share code, notes, and snippets.

@jetstreamin
Created March 5, 2019 11:32
Show Gist options
  • Save jetstreamin/60e4a5991be0bfe20d03df21ae496ff0 to your computer and use it in GitHub Desktop.
Save jetstreamin/60e4a5991be0bfe20d03df21ae496ff0 to your computer and use it in GitHub Desktop.
bash: read file to array
# 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