按欄位讀取字串欄位
我們假設欄位分隔符是:
var='line: 1
line: 2
line3'
while IFS= read -d : -r field || [ -n "$field" ]; do
echo "-$field-"
done <<< "$var"
輸出:
-line-
- 1
line-
- 2
line3
-
我們假設欄位分隔符是:
var='line: 1
line: 2
line3'
while IFS= read -d : -r field || [ -n "$field" ]; do
echo "-$field-"
done <<< "$var"
輸出:
-line-
- 1
line-
- 2
line3
-