I am trying to replace the first occurrence of a space in each line with a newline.
For instance
123 there is a monkey
567 there is also a tiger
would become
123
there is a monkey
567
there is also a tiger
I have tried doing this with the command:
sed -e 's/^\s\+/\n/g' output.txt > new.txt
with no luck. I am also open to any other programs in linux that would allow me to do this such as awk, perl, or bash.
You can use:
sed $'s/ \{1,\}/\\\n/' file
123
there is a monkey
567
there is also a tiger
This works both on BSD as well on gnu sed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With