SERD-SORT(1) General Commands Manual SERD-SORT(1)

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:

base
Base URI, path, or rebase to use the output path. See serd-pipe(1) for details.

syntax
Input syntax or option: NQuads, NTriples, TriG, Turtle, lax, variables, relative, or labels. See serd-pipe(1) for details.

syntax
Output syntax or option: empty, NQuads, NTriples, TriG, Turtle, ascii, contextual, expanded, verbatim, terse, or lax. See serd-pipe(1) for details.

Display version information and exit.

bytes
I/O block size. See serd-pipe(1) for details.

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.

Print the command line options.

bytes
Parser stack size. See serd-pipe(1) for details.

filename
Write output to the given filename instead of stdout.

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

serd-sort is a part of serd, by David Robillard d@drobilla.net.
August 12, 2021 Serd 0.30.11