Read lines of a string into an array
suggest changevar='line 1
line 2
line3'
readarray -t arr <<< "$var"
or with a loop:
arr=()
while IFS= read -r line; do
arr+=("$line")
done <<< "$var"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents