diff options
-rwxr-xr-x | foaf/rdf2turtle.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/foaf/rdf2turtle.sh b/foaf/rdf2turtle.sh new file mode 100755 index 0000000..676cd25 --- /dev/null +++ b/foaf/rdf2turtle.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +rdffile="$1" +ttlfile="${2:-$(basename "$rdffile" .rdf).ttl}" + +exit1() { + echo "ERROR: $1" + exit 1 +} + +[ -e "$rdffile" ] || exit1 "RDF file \"$rdffile\" does not exist." +[ ! -e "$ttlfile" ] || exit1 "Turtle file \"$ttlfile\" already exists." + +base="$(perl -ne '/\bxml:base="(http.+)"/ and print $1 and exit;' "$rdffile")" || true #' +rapper -i rdfxml ${base:+-O "$base"} -o turtle "$rdffile" > "$ttlfile" +perl -i -pe 's/ {4}/\t/g' "$ttlfile" |