Bash Read a file field by field


Example

Let's assume that the field separator is : (colon) in the file file.

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

For a content:

first : se
con
d:
    Thi rd:
    Fourth

The output is:

**first **
** se
con
d**
**
    Thi rd**
**
    Fourth
**