What's wrong with below code to split text block by newline?
#!/bin/bash
txt="abcd
efg hijk lmn
opq
rst"
lines=${txt%$'\n'*}
for line in $lines; do
echo $line
done
Current output is:
abcd
efg
hijk
lmn
opq
expected output:
abcd
efg hijk lmn
opq
rst