sed and newlines

sed’s really bad when it comes to newlines — and especially so on OSX. This snippet works quite well for “multiline” sedding:

test:
poops1
        poop
butts1
        butt

cat test |sed -e ':a' -e 'N' -e '$!ba' -e 's/s1\n        /s1, /g' 

output:
poops1, poop
butts1, butt

Leave a Reply