{
    "mode": "info",
    "parameter": "cut",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/cut/json",
    "generated": "2026-11-11T09:37:31Z",
    "sections": {
        "File: coreutils.info,  Node: cut invocation,  Next: paste invocation,  Up: Operating on fields": {
            "content": "",
            "subsections": [
                {
                    "name": "8.1 'cut': Print selected parts of lines",
                    "content": "'cut' writes to standard output selected parts of each line of each\ninput file, or standard input if no files are given or for a file name\nof '-'.  Synopsis:\n\ncut OPTION... [FILE]...\n\nIn the table which follows, the BYTE-LIST, CHARACTER-LIST, and\nFIELD-LIST are one or more numbers or ranges (two numbers separated by a\ndash) separated by commas.  Bytes, characters, and fields are numbered\nstarting at 1.  Incomplete ranges may be given: '-M' means '1-M'; 'N-'\nmeans 'N' through end of line or last field.  The list elements can be\nrepeated, can overlap, and can be specified in any order; but the\nselected input is written in the same order that it is read, and is\nwritten exactly once.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-b BYTE-LIST'\n'--bytes=BYTE-LIST'\nSelect for printing only the bytes in positions listed in\nBYTE-LIST.  Tabs and backspaces are treated like any other\ncharacter; they take up 1 byte.  If an output delimiter is\nspecified, (see the description of '--output-delimiter'), then\noutput that string between ranges of selected bytes.\n\n'-c CHARACTER-LIST'\n'--characters=CHARACTER-LIST'\nSelect for printing only the characters in positions listed in\nCHARACTER-LIST.  The same as '-b' for now, but internationalization\nwill change that.  Tabs and backspaces are treated like any other\ncharacter; they take up 1 character.  If an output delimiter is\nspecified, (see the description of '--output-delimiter'), then\noutput that string between ranges of selected bytes.\n\n'-f FIELD-LIST'\n'--fields=FIELD-LIST'\nSelect for printing only the fields listed in FIELD-LIST.  Fields\nare separated by a TAB character by default.  Also print any line\nthat contains no delimiter character, unless the '--only-delimited'\n('-s') option is specified.\n\nNote 'awk' supports more sophisticated field processing, like\nreordering fields, and handling fields aligned with blank\ncharacters.  By default 'awk' uses (and discards) runs of blank\ncharacters to separate fields, and ignores leading and trailing\nblanks.\nawk '{print $2}'      # print the second field\nawk '{print $(NF-1)}' # print the penultimate field\nawk '{print $2,$1}'   # reorder the first two fields\nNote while 'cut' accepts field specifications in arbitrary order,\noutput is always in the order encountered in the file.\n\nIn the unlikely event that 'awk' is unavailable, one can use the\n'join' command, to process blank characters as 'awk' does above.\njoin -a1 -o 1.2     - /dev/null # print the second field\njoin -a1 -o 1.2,1.1 - /dev/null # reorder the first two fields\n\n'-d INPUTDELIMBYTE'\n'--delimiter=INPUTDELIMBYTE'\nWith '-f', use the first byte of INPUTDELIMBYTE as the input\nfields separator (default is TAB).\n\n'-n'\nDo not split multi-byte characters (no-op for now).\n\n'-s'\n'--only-delimited'\nFor '-f', do not print lines that do not contain the field\nseparator character.  Normally, any line without a field separator\nis printed verbatim.\n\n'--output-delimiter=OUTPUTDELIMSTRING'\nWith '-f', output fields are separated by OUTPUTDELIMSTRING.  The\ndefault with '-f' is to use the input delimiter.  When using '-b'\nor '-c' to select ranges of byte or character offsets (as opposed\nto ranges of fields), output OUTPUTDELIMSTRING between\nnon-overlapping ranges of selected bytes.\n\n'--complement'\nThis option is a GNU extension.  Select for printing the complement\nof the bytes, characters or fields selected with the '-b', '-c' or\n'-f' options.  In other words, do not print the bytes, characters\nor fields specified via those options.  This option is useful when\nyou have many fields and want to print all but a few of them.\n\n'-z'\n'--zero-terminated'\nDelimit items with a zero byte rather than a newline (ASCII LF).\nI.e., treat input as items separated by ASCII NUL and terminate\noutput items with ASCII NUL. This option can be useful in\nconjunction with 'perl -0' or 'find -print0' and 'xargs -0' which\ndo the same in order to reliably handle arbitrary file names (even\nthose containing blanks or other special characters).\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}