Let’s say that you have a file and you would like to convert each line in the file to an element in an array.
The key to this is knowing about and how to manipulate the IFS (Internal Field Separator). The default IFS is whitespace (a space, tab, or newline) and if you create an array passing it a whitespace delimited list of strings, each token will be set to an element in the array.
ARRAY=(a b d
→ Continue reading “Creating an Array in Bash from a File With Each Element on a Separate Line”