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
inplace when the -i’ option is used.
Manually managed conf files can be blacklisted by add 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 |
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. |
Examples
To recursively sort all files
find . -name '*.conf' | xargs ksconf sort -i