Cool Bash One-Liner: SVN add all unadded files

nadeem.shabir | | Sunday, February 3rd, 2008
  1.  
  2. svn st | grep "^? " | awk ‘{ print $2 }’ | xargs svn add
  3.  
,

Cool Bash One-Liner: Post files to Platform Store

nadeem.shabir | | Sunday, February 3rd, 2008

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’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 … so I asked Rob, he showed me how to do this …

  1.  
  2. find . -name "*-issue.xml.rdf" | sed -e ’s!^\./\([0-9]*-issue.xml.rdf\)!curl -v -d @\1  -H content-type:application/rdf+xml http://api.talis.com/stores/kiyanwang-dev1/meta!’ | bash
  3.  

Cool, huh? :)

For the un-initiated, the find locates all the files I want to post which in my case ended with -issue.xml.rdf. The sed search and replace matches the filename, and then replaces it with a curl command, inserting the filename as a parameter @\1. Finally the generated curl command is piped to bash which executes each generated line.
.

,

Powered by WordPress | Theme by Roy Tanck