Bash Read a file (data stream, variable) line-by-line (and/or field-by-field)? Read fields of a file into an array


Example

Let's assume that the field separator is :

arr=()
while IFS= read -d : -r field || [ -n "$field" ]; do
   arr+=("$field")
done <file