{
    "mode": "info",
    "parameter": "ptx",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/ptx/json",
    "generated": "2026-11-15T15:39:28Z",
    "sections": {
        "File: coreutils.info,  Node: ptx invocation,  Next: tsort invocation,  Prev: comm invocation,  Up: Operating on sorted files": {
            "content": "",
            "subsections": [
                {
                    "name": "7.5 'ptx': Produce permuted indexes",
                    "content": "'ptx' reads a text file and essentially produces a permuted index, with\neach keyword in its context.  The calling sketch is either one of:\n\nptx [OPTION ...] [FILE ...]\nptx -G [OPTION ...] [INPUT [OUTPUT]]\n\nThe '-G' (or its equivalent: '--traditional') option disables all GNU\nextensions and reverts to traditional mode, thus introducing some\nlimitations and changing several of the program's default option values."
                }
            ]
        },
        "When '-G' is not specified, GNU extensions are always enabled.  GNU": {
            "content": "extensions to 'ptx' are documented wherever appropriate in this\ndocument.  *Note Compatibility in ptx::, for the full list.\n\nIndividual options are explained in the following sections.\n\nWhen GNU extensions are enabled, there may be zero, one or several\nFILEs after the options.  If there is no FILE, the program reads the\nstandard input.  If there is one or several FILEs, they give the name of\ninput files which are all read in turn, as if all the input files were\nconcatenated.  However, there is a full contextual break between each\nfile and, when automatic referencing is requested, file names and line\nnumbers refer to individual text input files.  In all cases, the program\noutputs the permuted index to the standard output.\n\nWhen GNU extensions are not enabled, that is, when the program\noperates in traditional mode, there may be zero, one or two parameters\nbesides the options.  If there are no parameters, the program reads the\nstandard input and outputs the permuted index to the standard output.",
            "subsections": []
        },
        "If there is only one parameter, it names the text INPUT to be read": {
            "content": "instead of the standard input.  If two parameters are given, they give\nrespectively the name of the INPUT file to read and the name of the\nOUTPUT file to produce.  Be very careful to note that, in this case,\nthe contents of file given by the second parameter is destroyed.  This\nbehavior is dictated by System V 'ptx' compatibility; GNU Standards\nnormally discourage output parameters not introduced by an option.\n\nNote that for any file named as the value of an option or as an\ninput text file, a single dash '-' may be used, in which case standard\ninput is assumed.  However, it would not make sense to use this\nconvention more than once per program invocation.\n\n* Menu:\n\n* General options in ptx::      Options which affect general program behavior.\n* Charset selection in ptx::    Underlying character set considerations.\n* Input processing in ptx::     Input fields, contexts, and keyword selection.\n* Output formatting in ptx::    Types of output format, and sizing the fields.\n* Compatibility in ptx::\n",
            "subsections": []
        },
        "File: coreutils.info,  Node: General options in ptx,  Next: Charset selection in ptx,  Up: ptx invocation": {
            "content": "'-G'\n'--traditional'\nAs already explained, this option disables all GNU extensions to\n'ptx' and switches to traditional mode.\n\n'--help'\nPrint a short help on standard output, then exit without further\nprocessing.\n\n'--version'\nPrint the program version on standard output, then exit without\nfurther processing.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n",
            "subsections": []
        },
        "File: coreutils.info,  Node: Charset selection in ptx,  Next: Input processing in ptx,  Prev: General options in ptx,  Up: ptx invocation": {
            "content": "",
            "subsections": []
        },
        "As it is set up now, 'ptx' assumes that the input file is coded using": {
            "content": "8-bit characters, and it may not work well in multibyte locales.  In a\nsingle-byte locale, the default regular expression for a keyword allows\nforeign or diacriticized letters.  Keyword sorting, however, is still\ncrude; it obeys the underlying character set ordering quite blindly.\n\nThe output of 'ptx' assumes the locale's character encoding.  For\nexample, with 'ptx''s '-T' option, if the locale uses the Latin-1\nencoding you may need a LaTeX directive like\n'\\usepackage[latin1]{inputenc}' to render non-ASCII characters\ncorrectly.\n\n'-f'\n'--ignore-case'\nFold lower case letters to upper case for sorting.\n",
            "subsections": []
        },
        "File: coreutils.info,  Node: Input processing in ptx,  Next: Output formatting in ptx,  Prev: Charset selection in ptx,  Up: ptx invocation": {
            "content": "'-b FILE'\n'--break-file=FILE'\n\nThis option provides an alternative (to '-W') method of describing\nwhich characters make up words.  It introduces the name of a file\nwhich contains a list of characters which cannot be part of one\nword; this file is called the \"Break file\".  Any character which is\nnot part of the Break file is a word constituent.  If both options\n'-b' and '-W' are specified, then '-W' has precedence and '-b' is\nignored.\n\nWhen GNU extensions are enabled, the only way to avoid newline as a\nbreak character is to write all the break characters in the file\nwith no newline at all, not even at the end of the file.  When GNU\nextensions are disabled, spaces, tabs and newlines are always\nconsidered as break characters even if not included in the Break\nfile.\n\n'-i FILE'\n'--ignore-file=FILE'\n\nThe file associated with this option contains a list of words which\nwill never be taken as keywords in concordance output.  It is\ncalled the \"Ignore file\".  The file contains exactly one word in\neach line; the end of line separation of words is not subject to\nthe value of the '-S' option.\n\n'-o FILE'\n'--only-file=FILE'\n\nThe file associated with this option contains a list of words which\nwill be retained in concordance output; any word not mentioned in\nthis file is ignored.  The file is called the \"Only file\".  The\nfile contains exactly one word in each line; the end of line\nseparation of words is not subject to the value of the '-S' option.\n\nThere is no default for the Only file.  When both an Only file and\nan Ignore file are specified, a word is considered a keyword only\nif it is listed in the Only file and not in the Ignore file.\n\n'-r'\n'--references'\n\nOn each input line, the leading sequence of non-white space\ncharacters will be taken to be a reference that has the purpose of\nidentifying this input line in the resulting permuted index.  *Note\nOutput formatting in ptx::, for more information about reference\nproduction.  Using this option changes the default value for option\n'-S'.\n\nUsing this option, the program does not try very hard to remove\nreferences from contexts in output, but it succeeds in doing so\nwhen the context ends exactly at the newline.  If option '-r' is\nused with '-S' default value, or when GNU extensions are disabled,\nthis condition is always met and references are completely excluded\nfrom the output contexts.\n\n'-S REGEXP'\n'--sentence-regexp=REGEXP'\n\nThis option selects which regular expression will describe the end\nof a line or the end of a sentence.  In fact, this regular\nexpression is not the only distinction between end of lines or end\nof sentences, and input line boundaries have no special\nsignificance outside this option.  By default, when GNU extensions\nare enabled and if '-r' option is not used, end of sentences are\nused.  In this case, this REGEX is imported from GNU Emacs:\n\n[.?!][]\\\"')}]*\\\\($\\\\|\\t\\\\|  \\\\)[ \\t\\n]*\n\nWhenever GNU extensions are disabled or if '-r' option is used, end\nof lines are used; in this case, the default REGEXP is just:\n\n\\n\n\nUsing an empty REGEXP is equivalent to completely disabling end of\nline or end of sentence recognition.  In this case, the whole file\nis considered to be a single big line or sentence.  The user might\nwant to disallow all truncation flag generation as well, through\noption '-F \"\"'.  *Note Syntax of Regular Expressions:\n(emacs)Regexps.\n\nWhen the keywords happen to be near the beginning of the input line\nor sentence, this often creates an unused area at the beginning of\nthe output context line; when the keywords happen to be near the\nend of the input line or sentence, this often creates an unused\narea at the end of the output context line.  The program tries to\nfill those unused areas by wrapping around context in them; the\ntail of the input line or sentence is used to fill the unused area\non the left of the output line; the head of the input line or\nsentence is used to fill the unused area on the right of the output\nline.\n\nAs a matter of convenience to the user, many usual backslashed\nescape sequences from the C language are recognized and converted\nto the corresponding characters by 'ptx' itself.\n\n'-W REGEXP'\n'--word-regexp=REGEXP'\n\nThis option selects which regular expression will describe each\nkeyword.  By default, if GNU extensions are enabled, a word is a\nsequence of letters; the REGEXP used is '\\w+'.  When GNU extensions\nare disabled, a word is by default anything which ends with a\nspace, a tab or a newline; the REGEXP used is '[^ \\t\\n]+'.\n\nAn empty REGEXP is equivalent to not using this option.  *Note\nSyntax of Regular Expressions: (emacs)Regexps.\n\nAs a matter of convenience to the user, many usual backslashed\nescape sequences, as found in the C language, are recognized and\nconverted to the corresponding characters by 'ptx' itself.\n",
            "subsections": []
        },
        "File: coreutils.info,  Node: Output formatting in ptx,  Next: Compatibility in ptx,  Prev: Input processing in ptx,  Up: ptx invocation": {
            "content": "",
            "subsections": []
        },
        "Output format is mainly controlled by the '-O' and '-T' options": {
            "content": "described in the table below.  When neither '-O' nor '-T' are selected,\nand if GNU extensions are enabled, the program chooses an output format\nsuitable for a dumb terminal.  Each keyword occurrence is output to the\ncenter of one line, surrounded by its left and right contexts.  Each\nfield is properly justified, so the concordance output can be readily\nobserved.  As a special feature, if automatic references are selected by\noption '-A' and are output before the left context, that is, if option\n'-R' is not selected, then a colon is added after the reference; this\nnicely interfaces with GNU Emacs 'next-error' processing.  In this\ndefault output format, each white space character, like newline and tab,\nis merely changed to exactly one space, with no special attempt to\ncompress consecutive spaces.  This might change in the future.  Except\nfor those white space characters, every other character of the\nunderlying set of 256 characters is transmitted verbatim.\n\nOutput format is further controlled by the following options.\n\n'-g NUMBER'\n'--gap-size=NUMBER'\n\nSelect the size of the minimum white space gap between the fields\non the output line.\n\n'-w NUMBER'\n'--width=NUMBER'\n\nSelect the maximum output width of each final line.  If references\nare used, they are included or excluded from the maximum output\nwidth depending on the value of option '-R'.  If this option is not\nselected, that is, when references are output before the left\ncontext, the maximum output width takes into account the maximum\nlength of all references.  If this option is selected, that is,\nwhen references are output after the right context, the maximum\noutput width does not take into account the space taken by\nreferences, nor the gap that precedes them.\n\n'-A'\n'--auto-reference'\n\nSelect automatic references.  Each input line will have an\nautomatic reference made up of the file name and the line ordinal,\nwith a single colon between them.  However, the file name will be\nempty when standard input is being read.  If both '-A' and '-r' are\nselected, then the input reference is still read and skipped, but\nthe automatic reference is used at output time, overriding the\ninput reference.\n\n'-R'\n'--right-side-refs'\n\nIn the default output format, when option '-R' is not used, any\nreferences produced by the effect of options '-r' or '-A' are\nplaced to the far right of output lines, after the right context.\nWith default output format, when the '-R' option is specified,\nreferences are rather placed at the beginning of each output line,\nbefore the left context.  For any other output format, option '-R'\nis ignored, with one exception: with '-R' the width of references\nis not taken into account in total output width given by '-w'.\n\nThis option is automatically selected whenever GNU extensions are\ndisabled.\n\n'-F STRING'\n'--flag-truncation=STRING'\n\nThis option will request that any truncation in the output be\nreported using the string STRING.  Most output fields theoretically\nextend towards the beginning or the end of the current line, or\ncurrent sentence, as selected with option '-S'.  But there is a\nmaximum allowed output line width, changeable through option '-w',\nwhich is further divided into space for various output fields.\nWhen a field has to be truncated because it cannot extend beyond\nthe beginning or the end of the current line to fit in, then a\ntruncation occurs.  By default, the string used is a single slash,\nas in '-F /'.\n\nSTRING may have more than one character, as in '-F ...'.  Also, in\nthe particular case when STRING is empty ('-F \"\"'), truncation\nflagging is disabled, and no truncation marks are appended in this\ncase.\n\nAs a matter of convenience to the user, many usual backslashed\nescape sequences, as found in the C language, are recognized and\nconverted to the corresponding characters by 'ptx' itself.\n\n'-M STRING'\n'--macro-name=STRING'\n\nSelect another STRING to be used instead of 'xx', while generating\noutput suitable for 'nroff', 'troff' or TeX.\n\n'-O'\n'--format=roff'\n\nChoose an output format suitable for 'nroff' or 'troff' processing.\nEach output line will look like:\n\n.xx \"TAIL\" \"BEFORE\" \"KEYWORDANDAFTER\" \"HEAD\" \"REF\"\n\nso it will be possible to write a '.xx' roff macro to take care of\nthe output typesetting.  This is the default output format when GNU\nextensions are disabled.  Option '-M' can be used to change 'xx' to\nanother macro name.\n\nIn this output format, each non-graphical character, like newline\nand tab, is merely changed to exactly one space, with no special\nattempt to compress consecutive spaces.  Each quote character '\"'\nis doubled so it will be correctly processed by 'nroff' or 'troff'.\n\n'-T'\n'--format=tex'\n\nChoose an output format suitable for TeX processing.  Each output\nline will look like:\n\n\\xx {TAIL}{BEFORE}{KEYWORD}{AFTER}{HEAD}{REF}\n\nso it will be possible to write a '\\xx' definition to take care of\nthe output typesetting.  Note that when references are not being\nproduced, that is, neither option '-A' nor option '-r' is selected,\nthe last parameter of each '\\xx' call is inhibited.  Option '-M'\ncan be used to change 'xx' to another macro name.\n\nIn this output format, some special characters, like '$', '%', '&',\n'#' and '' are automatically protected with a backslash.  Curly\nbrackets '{', '}' are protected with a backslash and a pair of\ndollar signs (to force mathematical mode).  The backslash itself\nproduces the sequence '\\backslash{}'.  Circumflex and tilde\ndiacritical marks produce the sequence '^\\{ }' and '~\\{ }'\nrespectively.  Other diacriticized characters of the underlying\ncharacter set produce an appropriate TeX sequence as far as\npossible.  The other non-graphical characters, like newline and\ntab, and all other characters which are not part of ASCII, are\nmerely changed to exactly one space, with no special attempt to\ncompress consecutive spaces.  Let me know how to improve this\nspecial character processing for TeX.\n",
            "subsections": []
        },
        "File: coreutils.info,  Node: Compatibility in ptx,  Prev: Output formatting in ptx,  Up: ptx invocation": {
            "content": "",
            "subsections": []
        },
        "This version of 'ptx' contains a few features which do not exist in": {
            "content": "",
            "subsections": []
        },
        "System V 'ptx'.  These extra features are suppressed by using the '-G'": {
            "content": "command line option, unless overridden by other command line options.",
            "subsections": []
        },
        "Some GNU extensions cannot be recovered by overriding, so the simple": {
            "content": "rule is to avoid '-G' if you care about GNU extensions.  Here are the\ndifferences between this program and System V 'ptx'.\n\n* This program can read many input files at once, it always writes\nthe resulting concordance on standard output.  On the other hand,\nSystem V 'ptx' reads only one file and sends the result to standard\noutput or, if a second FILE parameter is given on the command, to\nthat FILE.\n\nHaving output parameters not introduced by options is a dangerous\npractice which GNU avoids as far as possible.  So, for using 'ptx'\nportably between GNU and System V, you should always use it with a\nsingle input file, and always expect the result on standard output.\nYou might also want to automatically configure in a '-G' option to\n'ptx' calls in products using 'ptx', if the configurator finds that\nthe installed 'ptx' accepts '-G'.\n\n* The only options available in System V 'ptx' are options '-b',\n'-f', '-g', '-i', '-o', '-r', '-t' and '-w'.  All other options are\nGNU extensions and are not repeated in this enumeration.  Moreover,\nsome options have a slightly different meaning when GNU extensions\nare enabled, as explained below.\n\n* By default, concordance output is not formatted for 'troff' or\n'nroff'.  It is rather formatted for a dumb terminal.  'troff' or\n'nroff' output may still be selected through option '-O'.\n\n* Unless '-R' option is used, the maximum reference width is\nsubtracted from the total output line width.  With GNU extensions\ndisabled, width of references is not taken into account in the\noutput line width computations.\n\n* All 256 bytes, even ASCII NUL bytes, are always read and processed\nfrom input file with no adverse effect, even if GNU extensions are\ndisabled.  However, System V 'ptx' does not accept 8-bit\ncharacters, a few control characters are rejected, and the tilde\n'~' is also rejected.\n\n* Input line length is only limited by available memory, even if GNU\nextensions are disabled.  However, System V 'ptx' processes only\nthe first 200 characters in each line.\n\n* The break (non-word) characters default to be every character\nexcept all letters of the underlying character set, diacriticized\nor not.  When GNU extensions are disabled, the break characters\ndefault to space, tab and newline only.\n\n* The program makes better use of output line width.  If GNU\nextensions are disabled, the program rather tries to imitate System\nV 'ptx', but still, there are some slight disposition glitches this\nprogram does not completely reproduce.\n\n* The user can specify both an Ignore file and an Only file.  This is\nnot allowed with System V 'ptx'.\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}