5.8.5 Built-in Registers

Predefined registers whose identifiers start with a dot are read-only. Many are Boolean-valued, interpolating a true or false value testable with the if, ie, or while requests.

Caution: Built-in registers are subject to removal like others; once removed, they can be recreated only as normal writable registers and will not otherwise reflect the configuration of the formatter.

A register name is often associated with a request of the same name (without the dot). A complete listing of all built-in registers can be found in Register Index.

We present here a few built-in registers that are not described elsewhere in this manual; they have to do with invariant properties of GNU troff, or obtain information about the formatter’s command-line options, processing progress, or the operating environment.

\n[.A]

Approximate output is being formatted (Boolean-valued); see groff’s -a option (Options).

\n[.c]
\n[c.]

Input line number. ‘c.’ is a writable synonym, affecting subsequent interpolations of both ‘.c’ and ‘c.’.

\n[.F]

Name of input file (string-valued).

\n[.g]

Always true in GNU troff (Boolean-valued). Documents can use this to ask the formatter if it claims groff compatibility.

\n[.P]

Output page selection status (Boolean-valued); see groff’s -o option (Options).

\n[.R]

Count of available unused registers; in GNU troff this register always interpolates the maximum representable integer.73 Favor its use over numeric literals with many zeroes or nines to indicate an arbitrary large quantity.

\n[.T]

Indicator of output device selection (Boolean-valued); see groff’s -T option (Options).

\n[.U]

Unsafe mode enablement status (Boolean-valued); see groff’s -U option (Options).

\n[.x]

Major version number of the running GNU troff formatter. For example, if the version number is 1.23.0, then .x contains ‘1’.

\n[.y]

Minor version number of the running GNU troff formatter. For example, if the version number is 1.23.0, then .y contains ‘23’.

\n[.Y]

Revision number of the running GNU troff formatter. For example, if the version number is 1.23.0, then .Y contains ‘0’.

\n[$$]

Process identifier (PID) of the GNU troff program in its operating environment.

Date- and time-related registers are set per the local time as determined by localtime(3) when the formatter launches. This initialization can be influenced by the environment variable TZ or overridden by SOURCE_DATE_EPOCH; see Environment.

\n[seconds]

Count of seconds elapsed in the minute (0–60).

\n[minutes]

Count of minutes elapsed in the hour (0–59).

\n[hours]

Count of hours elapsed since midnight (0–23).

\n[dw]

Day of the week (1–7; 1 is Sunday).

\n[dy]

Day of the month (1–31).

\n[mo]

Month of the year (1–12).

\n[year]

Gregorian year.

\n[yr]

Gregorian year minus 1900. This register is incorrectly documented in the AT&T troff manual as storing the last two digits of the current year. That claim stopped being true in 2000. Old troff input that looks like:

'\" The year number is a surprise after 1999.
This document was formatted in 19\n(yr.

can be corrected to:

This document was formatted in \n[year].

or, for portability across many roff programs, to the following.

.nr y4 1900+\n(yr
This document was formatted in \n(y4.

If you wish to embed the date and/or time of a document’s formatting into its output, interpolate these registers into its text. Use the af request to format their values for output.

.af year 0000
.af mo 00
.af dy 00
.af hours 00
.af minutes 00
.af seconds 00
ISO 8601 date stamp:
\n[year]-\n[mo]-\n[dy]T\n[hours]:\n[minutes]:\n[seconds]
    ⇒ ISO 8601 date stamp: 2025-12-07T02:17:54