{"id":829,"date":"2015-03-11T04:11:00","date_gmt":"2015-03-11T04:11:00","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=829"},"modified":"2015-03-11T04:13:15","modified_gmt":"2015-03-11T04:13:15","slug":"sed-1-etchosts-extra-characters-at-the-end-of-h-command","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2015\/03\/11\/sed-1-etchosts-extra-characters-at-the-end-of-h-command\/","title":{"rendered":"sed: 1: &#8220;\/etc\/hosts&#8221;: extra characters at the end of h command"},"content":{"rendered":"<p>I was trying a simple <strong>sed -i<\/strong> on my Mac and was running into <\/p>\n<blockquote><p>\n# Does NOT work on Mac<br \/>\n$ sed -i &#8216;s\/^192.168.*vm\/192.168.1.12   vm\/&#8217; \/etc\/hosts<br \/>\nsed: 1: &#8220;\/etc\/hosts&#8221;: extra characters at the end of h command\n<\/p><\/blockquote>\n<p>A quick google search resulted in <a href=\"http:\/\/stackoverflow.com\/questions\/7648328\/getting-sed-error\">stackoverflow getting sed error<\/a> which has the solution. Apparently, Mac uses <em>BSD sed<\/em> and Linux uses <em>GNU sed<\/em> which have different set of arguments. So provide the extra argument in Mac as shown below.<\/p>\n<blockquote><p>\n# Adding the extra argument will work on your Mac<br \/>\n$ sed -i &#8221; &#8216;s\/^192.168.*vm\/192.168.1.12   vm\/&#8217; \/etc\/hosts\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I was trying a simple sed -i on my Mac and was running into # Does NOT work on Mac $ sed -i &#8216;s\/^192.168.*vm\/192.168.1.12 vm\/&#8217; \/etc\/hosts sed: 1: &#8220;\/etc\/hosts&#8221;: extra characters at the end of h command A quick google search resulted in stackoverflow getting sed error which has the solution. Apparently, Mac uses BSD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,34],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/829"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=829"}],"version-history":[{"count":3,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/829\/revisions"}],"predecessor-version":[{"id":832,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/829\/revisions\/832"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}