{"id":313,"date":"2008-02-03T10:33:34","date_gmt":"2008-02-03T10:33:34","guid":{"rendered":"https:\/\/virtualchaos.co.uk\/blog\/2008\/02\/03\/cool-bash-one-liner-post-files-to-platform-store\/"},"modified":"2008-02-03T10:39:27","modified_gmt":"2008-02-03T10:39:27","slug":"cool-bash-one-liner-post-files-to-platform-store","status":"publish","type":"post","link":"https:\/\/virtualchaos.co.uk\/blog\/2008\/02\/03\/cool-bash-one-liner-post-files-to-platform-store\/","title":{"rendered":"Cool Bash One-Liner: Post files to Platform Store"},"content":{"rendered":"<p>As part of some small prototyping activity I had to convert a whole load of data into rdf. My problem was that the files I had generated were scattered around in a very hierarchical directory structure, but all I wanted to do was find them and most them to a platform store. I really didn&#8217;t want to have to post them one at time manually. I knew I could do it using a bash script but my scripting was a bit rusty &#8230; so I asked <a href=\"http:\/\/www.dynamicorange.com\/blog\/\">Rob<\/a>, he showed me how to do this &#8230; <\/p>\n<div class=\"dean_ch\" style=\"white-space: wrap;\">\n<ol>\n<li class=\"li1\">\n<div class=\"de1\">span class=&#8221;st0&#8243;>&quot;*-issue.xml.rdf&quot;<\/span><span class=\"st0\">&#8216;s!^<span class=\"es0\">\\.<\/span>\/<span class=\"es0\">\\(<\/span>[0-9]*-issue.xml.rdf<span class=\"es0\">\\)<\/span>!curl -v -d @<span class=\"es0\">\\1<\/span> &nbsp;-H content-type:application\/rdf+xml http:\/\/api.talis.com\/stores\/kiyanwang-dev1\/meta!&#8217;<\/span<\/div>\n<\/li>\n<\/ol>\n<\/div>\n<p>Cool, huh? \ud83d\ude42<\/p>\n<p>For the un-initiated, the <b>find<\/b> locates all the files I want to post which in my case ended with <em>-issue.xml.rdf<\/em>. The <b>sed<\/b> search and replace matches the filename, and then replaces it with a curl command, inserting the filename as a parameter <b>@\\1<\/b>. Finally the generated curl command is piped to bash which executes each generated line.<br \/>\n.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of some small prototyping activity I had to convert a whole load of data into rdf. My problem was that the files I had generated were scattered around in a very hierarchical directory structure, but all I wanted &hellip; <a href=\"https:\/\/virtualchaos.co.uk\/blog\/2008\/02\/03\/cool-bash-one-liner-post-files-to-platform-store\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[272,399],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash-one-liner","tag-talis"],"_links":{"self":[{"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=313"}],"version-history":[{"count":0,"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"wp:attachment":[{"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualchaos.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}