{"id":647,"date":"2018-09-14T00:44:58","date_gmt":"2018-09-13T19:14:58","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=647"},"modified":"2018-09-14T00:44:58","modified_gmt":"2018-09-13T19:14:58","slug":"curl-command-new-line-post-output","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=647","title":{"rendered":"Curl Command New Line Post Output"},"content":{"rendered":"<p>I like to use curl instead of UI tools like Postman for debugging my RESTful web services traffic whenever possible. I however didn&#8217;t like my output being messed up by the bash prompt being suffixed to the output. Something like the following:<\/p>\n<pre class=\"p1\"><span class=\"s1\">$ curl -H \"$auth_token\" http:\/\/localhost:8080\/xyz\/abc-efg\r\n<\/span><span class=\"s1\">[\"-\",\"A\",\"B\",\"C\",\"D\",\"E\"]$<\/span><\/pre>\n<p>So basically what I needed was to have a new line forced after the curl output. A quick search on internet yielded <a href=\"https:\/\/stackoverflow.com\/questions\/12849584\/automatically-add-newline-at-end-of-curl-response-body\">this article<\/a>. So I executed the following command on my terminal.<\/p>\n<pre class=\"p1\"><span class=\"s1\">$ echo '-w \"\\n\"' &gt;&gt; ~\/.curlrc<\/span><\/pre>\n<p>After doing this when I execute the same curl command I get the following output.<\/p>\n<pre class=\"p1\"><span class=\"s1\">$ curl -H \"$auth_token\" http:\/\/localhost:8080\/xyz\/abc-efg\r\n[\"-\",\"A\",\"B\",\"C\",\"D\",\"E\"]\r\n<\/span><span class=\"s1\">$\r\n<\/span><\/pre>\n<p>So now the bash prompt is actually coming on a new line by default!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like to use curl instead of UI tools like Postman for debugging my RESTful web services traffic whenever possible. I however didn&#8217;t like my output being messed up by the bash prompt being suffixed to the output. Something like the following: $ curl -H &#8220;$auth_token&#8221; http:\/\/localhost:8080\/xyz\/abc-efg [&#8220;-&#8220;,&#8221;A&#8221;,&#8221;B&#8221;,&#8221;C&#8221;,&#8221;D&#8221;,&#8221;E&#8221;]$ So basically what I needed was to [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,35,24],"tags":[],"class_list":["post-647","post","type-post","status-publish","format-standard","hentry","category-linux-os","category-mac-os","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=647"}],"version-history":[{"count":1,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/647\/revisions"}],"predecessor-version":[{"id":648,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/647\/revisions\/648"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}