sgfutils

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 sgf.

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

sgf

% sgf [options] [files]
The program sgf reads an SGF file from stdin, polishes it a bit, and writes it to stdout. For example,
% sgf < in.sgf > out.sgf
turns
% cat in.sgf
(;PB[Cho Chikun]BR[9th dan]PW[Takemiya Masaki]WR[9-Dan]DT[2/3 October 1996]
KM[5 1/2]RE[B+11.5];B[pd];W[dp];B[pp];W[dd];B[fq];W[dn];B[jp];W[qk];B[qm];W[pg];
B[nd];W[qf];B[qe];W[pj];B[cl];W[ci];B[el];W[fp];B[gp];W[fo];B[er];W[dr];B[dq];
W[cq];B[eq];W[bp];B[ei];W[dg];B[fc];W[dc];B[ic];W[cj];B[eg];W[df];
B[oq];W[hn];B[gl];W[hp];B[hq];W[go];B[gq];W[dk];B[gj];W[dl]C[];C[...])
into
% cat out.sgf
(;
PB[Cho Chikun]
BR[9d]
PW[Takemiya Masaki]
WR[9d]
KM[5.5]
RE[B+11.5]
DT[1996-10-02,03]

;B[pd];W[dp];B[pp];W[dd];B[fq];W[dn];B[jp];W[qk];B[qm];W[pg]
;B[nd];W[qf];B[qe];W[pj];B[cl];W[ci];B[el];W[fp];B[gp];W[fo]
;B[er];W[dr];B[dq];W[cq];B[eq];W[bp];B[ei];W[dg];B[fc];W[dc]
;B[ic];W[cj];B[eg];W[df];B[oq];W[hn];B[gl];W[hp];B[hq];W[go]
;B[gq];W[dk];B[gj];W[dl];
C[...]
)

It tries to normalize some fields such as rank and date and komi, and complains when it does not understand the date.

Options:

When given several input files, sgf will concatenate them, and output a game collection.