#!/bin/bash # makerdf.sh - Update an RDF File In-Place # Author: Sean B. Palmer, inamidst.com # Make a backup of the input [[ -d ~/.makerdf ]] || mkdir ~/.makerdf MD5=$(md5sum $1 | cut -d' ' -f 1) cp -p $1 ~/.makerdf/$MD5.rdf if [[ ! -f ~/.makerdf/$MD5.rdf ]] then echo "Error! Couldn't create backup" exit 1 fi # Put the Notation3 in a temporary file N3TMP=$$.makerdf.n3.tmp sed -n '// p' $1 | \ sed '1 s/^/# /; $ s/^/# /' > $N3TMP # Check that we got some output grep . $N3TMP &> /dev/null if (( $? )) then echo 'Error! Got zero triples' rm -f $N3TMP exit 1 fi # Update the file in-place cwm --n3 $N3TMP --rdf | \ egrep -v '