Looping through a string line by line

suggest change
var='line 1
line 2
line3'
while IFS= read -r line; do
   echo "-$line-"
done <<< "$var"

or

readarray -t arr <<< "$var"
for i in "${arr[@]}";do
    echo "-$i-"
done

Feedback about page:

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



Table Of Contents