Read a file field by field

suggest change

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
**

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents