{
    "mode": "man",
    "parameter": "GROG",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/GROG/1/json",
    "generated": "2026-11-13T02:41:28Z",
    "sections": {
        "Name": {
            "content": "grog - “groff guess”—infer the groff command a document requires\n",
            "subsections": []
        },
        "Synopsis": {
            "content": "grog [--run] [--ligatures] [groff-option ...] [--] [file ...]\n",
            "subsections": [
                {
                    "name": "grog -h",
                    "content": ""
                },
                {
                    "name": "grog --help",
                    "content": ""
                },
                {
                    "name": "grog -v",
                    "content": ""
                },
                {
                    "name": "grog --version",
                    "content": ""
                }
            ]
        },
        "Description": {
            "content": "grog  reads  its  input  and  guesses  which groff(1) options are needed to render it.  If no\noperands are given, or if file is “-”, grog reads the standard input stream.  The correspond‐\ning groff command is normally written to the standard output stream.  With the option  --run,\nthe inferred command is written to the standard error stream and then executed.\n",
            "subsections": []
        },
        "Options": {
            "content": "",
            "subsections": [
                {
                    "name": "-h   --help  -v  --version",
                    "content": "all exit afterward.\n",
                    "flag": "-v",
                    "long": "--version"
                },
                {
                    "name": "--ligatures",
                    "content": "includes the arguments -P-y -PU in the inferred groff command.   These  are  supported\nonly by the pdf output device.\n\n--run  writes the inferred command to the standard error stream and then executes it.\n\nAll  other  specified  short options (that is, arguments beginning with a minus sign “-” fol‐\nlowed by a letter) are interpreted as groff options or option clusters with or without an op‐\ntion argument.  Such options are included in the constructed groff command line.\n",
                    "long": "--ligatures"
                }
            ]
        },
        "Details": {
            "content": "grog reads each file operand, pattern-matching strings that are statistically  likely  to  be\ncharacteristic  of roff(7) documents.  It tries to guess which of the following groff options\nare required to correctly render the input: -e, -g, -G, -j, -p, -R, -t  (preprocessors);  and",
            "subsections": [
                {
                    "name": "-man -mdoc -mdoc-old -me -mm -mom -ms",
                    "content": "including these options and any file parameters is written to the standard output stream.\n\nIt is possible to specify arbitrary groff options on the command line.  These are included in\nthe  inferred  command  without  change.   Choices of groff options include -C to enable AT&T\ntroff compatibility mode and -T to select a non-default output device.  If the input  is  not\nencoded  in  US-ASCII,  ISO 8859-1, or IBM code page 1047, specification of a groff option to\nrun the preconv(1) preprocessor is advised; see the -D, -k, and -K options of groff(1).   For\nUTF-8 input, -k is a good choice.\n\ngroff  may issue diagnostic messages when an inappropriate -m option, or multiple conflicting\nones, are specified.  Consequently, it is best to specify no -m options  to  grog  unless  it\ncannot correctly infer all of the -m arguments a document requires.  A roff document can also\nbe  written  without  recourse  to any macro package.  In such cases, grog will infer a groff\ncommand without an -m option.\n"
                },
                {
                    "name": "Limitations",
                    "content": "grog presumes that the input does not change the escape, control, or no-break control charac‐\nters.  grog does not parse roff input line continuation or control structures  (brace  escape\nsequences and the “if”, “ie”, and “el” requests) nor groff's “while”.  Thus the input\n.if \\\nt .NH 1\n.if n .SH\nIntroduction\nwill  conceal  the use of the ms macros NH and SH from grog.  Such constructions are regarded\nby grog's implementors as insufficiently common to cause many inference problems.  Preproces‐\nsors can be even stricter when matching macro calls that bracket the regions of an input file\nthey replace.  pic, for example, requires PS, PE, and PF calls to immediately follow the  de‐\nfault control character at the beginning of a line.\n\nDetection of the -s option (the soelim(1) preprocessor) is tricky; to correctly infer its ne‐\ncessity  would  require  grog to recursively open all files given as arguments to the .so re‐\nquest under the same conditions that soelim itself does so; see its man  page.   Recall  that\nsoelim  is  necessary  only  if  sourced  files  need  to  be  preprocessed.  Therefore, as a\nworkaround, you may want to run the input through soelim manually, piping  it  to  grog,  and\ncompare  the  output  to  running grog on the input directly.  If the “soelim”ed input causes\ngrog to infer additional preprocessor options, then -s is likely necessary.\n\n$ printf \".TS\\nl.\\nI'm a table.\\n.TE\\n\" > 3.roff\n$ printf \".so 3.roff\\n\" > 2.roff\n$ printf \".XP\\n.so 2.roff\\n\" > 1.roff\n$ grog 1.roff\ngroff -ms 1.roff\n$ soelim 1.roff | grog\ngroff -t -ms -\n\nIn the foregoing example, we see that this procedure enabled grog to detect tbl(1) macros, so\nwe would add -s as well as the detected -t option to a revised grog or groff command.\n\n$ grog -st 1.roff\ngroff -st -ms 1.roff\n"
                }
            ]
        },
        "Exit status": {
            "content": "grog exits with error status 1 if a macro package appears to be in use by the input document,\nbut grog was unable to infer which one, or 2 if there were problems  handling  an  option  or\noperand.   It otherwise exits with status 0.  (If the --run option is specified, groff's exit\nstatus is discarded.)  Inferring no preprocessors or macro packages is not  an  error  condi‐\ntion;  a  valid roff document need not use either.  Even plain text is valid input, if one is\nmindful of the syntax of the control and escape characters.\n",
            "subsections": []
        },
        "Examples": {
            "content": "Running\ngrog /usr/share/doc/groff-base/meintro.me\nat the command line results in\ngroff -me /usr/share/doc/groff-base/meintro.me\nbecause grog recognizes that the file meintro.me is written using macros from the me package.\nThe command\ngrog /usr/share/doc/groff-base/pic.ms\noutputs\ngroff -e -p -t -ms /usr/share/doc/groff-base/pic.ms\non the other hand.  Besides discerning the ms macro package, grog recognizes  that  the  file\npic.ms additionally needs the combination of -t for tbl, -e for eqn, and -p for pic.\n\nConsider  a  file  doc/grnexampl.me,  which uses the grn preprocessor to include a gremlin(1)\npicture file in an me document.  Let's say we want to suppress color output,  produce  a  DVI\nfile, and get backtraces for any errors that troff encounters.  The command\ngrog -bc -Idoc -Tdvi doc/grnexmpl.me\nis processed by grog into\ngroff -bc -Idoc -Tdvi -e -g -me doc/grnexmpl.me\nwhere  we can see that grog has inferred the me macro package along with the eqn and grn pre‐\nprocessors.  (The input file is located in /usr/share/doc/groff-base if  you'd  like  to  try\nthis example yourself.)\n",
            "subsections": []
        },
        "Authors": {
            "content": "grog  was  originally  written in Bourne shell by James Clark.  The current implementation in\nPerl was written by Bernd Warken and heavily revised by G. Branden Robinson.\n\nSee also\ngroff(1)\n\ngroff 1.23.0                                31 March 2024                                    grog(1)",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}