Read a string field by field
suggest changeLet’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
-
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents