逐行循环一个字符串
var='line 1
line 2
line3'
while IFS= read -r line; do
echo "-$line-"
done <<< "$var"
要么
readarray -t arr <<< "$var"
for i in "${arr[@]}";do
echo "-$i-"
done
var='line 1
line 2
line3'
while IFS= read -r line; do
echo "-$line-"
done <<< "$var"
要么
readarray -t arr <<< "$var"
for i in "${arr[@]}";do
echo "-$i-"
done