The package sgfutils contains a few command line utilities that help working with SGF files that describe go (igo, weiqi, baduk) games. This page is about sgfx.

See also sgf, sgfcharset, sgfcheck, sgfcmp, sgfdb, sgfdbinfo, sgfinfo, sgfmerge, sgfsplit, sgfstrip, sgftf, sgftopng, sgfvarsplit, ugi2sgf.


% sgfx [options] [input]

The utility sgfx reads a single SGF file, and reports on the number of games, the number of variations, the number of moves in each variation, the properties (e.g. labels or comments) for a given move, the moves following a given move, etc.

The input file is the only non-option parameter if there is one. Otherwise input is read from stdin. This utility operates on a single game, and if the input is a multi-game file, then -g asks for the number of games in the input file, and -g12 selects game number 12 from the input.


Following parameters are filenames, not options.
-after ab,cd,ef
This is an option with a single parameter that is a sequence of moves starting at the current move (or the start of the game). Select the move in the tree (if any) reached by playing this sequence.
Print the number of the first move where the current variation differs from the previous.
Select the current variation only, turning the variation tree into a linear game.
Print the number of games in the input file.
Select game number 7 in the input file. (By default the first game is used.)
Print the current move.
Print the number of moves in the current variation.
Select move #12. Default is move #0, the root node.
Print the numbers of the moves in the current variation that have additional properties (other than the move itself, e.g. labels or comments).
Print the properties (tags) for the current move.
Print the value of property XY for the current move. E.g., -propC will print a comment.
Quiet: suppress some informative messages.
Print the replies to the current move discussed in this file.
-s", "
Define the separator for the output of multiple values via -propXY.
Print the move numbers of the tree of variations.
Print the number of variations in the current game.
Select variation 5 in the current game. (By default the first variation is used.)
Synonym for -g.

For example,

% cat prob0.sgf
C[W kan kill the B group. How?]
(;W[aa];B[ba]C[B lives])
(;W[ca];B[ba]C[B lives])

% sgfx -g prob0.sgf
1 game

% sgfx -v prob0.sgf
4 variations

% sgfx -v1 -m prob0.sgf
1 move

% sgfx -m0 -prop prob0.sgf

% sgfx -m0 -propAB prob0.sgf
ab, bb, cb, da, db

% sgfx -propAB -s: prob0.sgf

% sgfx -propPL -propC prob0.sgf
W kan kill the B group. How?

% sgfx -replies prob0.sgf
ba aa ca gg

% sgfx -after ba -prop prob0.sgf

% sgfx -after ba -propC prob0.sgf

% sgfx -after aa -replies prob0.sgf

% sgfx -after aa,ba -propC prob0.sgf
B lives