serd-sort
—
reorder RDF statements
serd-sort |
[-htV ] [-B
base] [-I
syntax] [-O
syntax] [-b
bytes] [-c
collation] [-f
pattern_file] [-k
bytes] [-o
filename] pattern
input ... |
serd-sort
reorders statements in RDF data by loading
everything into memory then rewriting it. By default, a “pretty”
ordering is used which is ideal for pretty-printing to Turtle or TriG. The
-c
option can be used to request a specific ordering,
which is mainly useful when emitting a line-based syntax like NTriples or
NQuads in a pipeline.
The options are as follows:
-B
base
- Base URI, path, or
rebase
to use the output path.
See serd-pipe(1) for details.
-I
syntax
- Input syntax or option:
NQuads
,
NTriples
, TriG
,
Turtle
, lax
,
variables
, relative
, or
labels
. See
serd-pipe(1) for details.
-O
syntax
- Output syntax or option:
empty
,
NQuads
, NTriples
,
TriG
, Turtle
,
ascii
, contextual
,
expanded
, verbatim
,
terse
, or lax
. See
serd-pipe(1) for details.
-V
- Display version information and exit.
-b
bytes
- I/O block size. See serd-pipe(1)
for details.
-c
collation
- A specific collation (statement ordering) to use. This can be any ordering
of the characters “SPO”, which stand for the subject,
predicate, and object of statements. Optionally, “G” can be
added as the first character, which will sort graph-first. Concretely, the
valid values are:
SPO
,
SOP
, OPS
,
OSP
, PSO
,
POS
, GSPO
,
GSOP
, GOPS
,
GOSP
, GPSO
, and
GPOS
.
-h
- Print the command line options.
-k
bytes
- Parser stack size. See
serd-pipe(1) for details.
-o
filename
- Write output to the given filename instead of
stdout.
-t
- Do not write type as “a” before other properties. Instead,
rdf:type will be written in order like any other property.
serd-sort
exits with a status of 0, or non-zero if an
error occured.
To pretty-print a file:
$ serd-sort -o pretty.ttl
input.ttl
To print statements ordered by predicate, subject, then
object:
$ serd-sort -c PSO
input.ttl