Read a string field by field

suggest change

Let’s assume that the field separator is :

var='line: 1
line: 2
line3'
while IFS= read -d : -r field || [ -n "$field" ]; do
   echo "-$field-"
done <<< "$var"

Output:

-line-
- 1
line-
- 2
line3
-

Feedback about page:

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



Table Of Contents