{"id":113,"date":"2012-03-02T20:58:46","date_gmt":"2012-03-03T04:58:46","guid":{"rendered":"http:\/\/www.lorrin.org\/blog\/?p=113"},"modified":"2012-03-16T23:24:36","modified_gmt":"2012-03-17T06:24:36","slug":"inserting-newlines-with-sed-on-os-x","status":"publish","type":"post","link":"https:\/\/www.lorrin.org\/blog\/2012\/03\/02\/inserting-newlines-with-sed-on-os-x\/","title":{"rendered":"Inserting newlines with sed on OS X"},"content":{"rendered":"<p>Out of the box, inserting newlines does not work with sed on OS X:<\/p>\n<pre class=\"brush:shell\">% echo foo,bar,baz | sed -e 's\/,\/\\n\/g'            \r\nfoonbarnbaz<\/pre>\n<p>The simple solution is to use GNU sed, which is already installed (as gsed), instead of the default BSD version:<\/p>\n<pre class=\"brush:shell\">% echo foo,bar,baz | gsed -e 's\/,\/\\n\/g'           \r\nfoo\r\nbar\r\nbaz<\/pre>\n<p>Alternatively, it is possible (though fiddly) to <a href=\"https:\/\/cafenate.wordpress.com\/2010\/12\/05\/newlines-in-sed-on-mac\/\">trick BSD sed into inserting newlines using extquotes<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Out of the box, inserting newlines does not work with sed on OS X: % echo foo,bar,baz | sed -e &#8216;s\/,\/\\n\/g&#8217; foonbarnbaz The simple solution is to use GNU sed, which is already installed (as gsed), instead of the default BSD version: % echo foo,bar,baz | gsed -e &#8216;s\/,\/\\n\/g&#8217; foo bar baz Alternatively, it is <a href='https:\/\/www.lorrin.org\/blog\/2012\/03\/02\/inserting-newlines-with-sed-on-os-x\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[91,30,36],"_links":{"self":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/113"}],"collection":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":3,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":151,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/113\/revisions\/151"}],"wp:attachment":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}