ksconf sort

Sort a Splunk .conf file. Sort has two modes: (1) by default, the sorted config file will be echoed to the screen. (2) the config files are updated in-place when the -i option is used.

Manually managed conf files can be protected against changes by adding a comment containing the string KSCONF-NO-SORT to the top of any .conf file.

usage: ksconf sort [-h] [--target FILE | --inplace] [-F] [-q] [-n LINES]
                   FILE [FILE ...]

Positional Arguments

FILE Input file to sort, or standard input.

Named Arguments

--target, -t File to write results to. Defaults to standard output.
--inplace, -i

Replace the input file with a sorted version.

WARNING: This a potentially destructive operation that may move/remove comments.

-n, --newlines Number of lines between stanzas.

In-place update arguments

-F, --force Force file sorting for all files, even for files containing the special ‘KSCONF-NO-SORT’ marker.
-q, --quiet Reduce the output. Reports only updated or invalid files. This is useful for pre-commit hooks, for example.

See also

Pre-commit hooks

See Pre-commit hooks for more information about how the sort command can be easily integrated in your git workflow.


To recursively sort all files

find . -name '*.conf' | xargs ksconf sort -i