I currently have a a
bash variable that holds a string similar to this one,
where each different phrase is separated by a newline:
var="1st word 2nd word 4th word"
Note there is an empty space in between
"2nd word" and
I would like to place these phrases into an array as such, keeping the empty string in the 2nd index:
arr=("1st word" "2nd word" "" "4th word")
I tried the following code but it seems to ignore the empty space.
IFS=$'\n' read -rd '' -a arr <<<"$var"
Anyone happens to have a solution to this?