Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

grep(1)

paste(1)



  cut(1)                              CLIX                              cut(1)



  NAME

    cut - Cuts out selected fields of each line of a file

  SYNOPSIS

    cut -clist [file ... ]

    cut -flist [-d char] [-s] [file ... ]

  FLAGS

    list      A comma-separated list of integer field numbers (in ascending
              order), with optional - to indicate ranges [for example, 1,4,7;
              1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through
              last field)].

    -clist    The list following -c (no space) specifies character positions
              (for example, -c1-72 would pass the first 72 characters of each
              line).

    -flist    The list following -f is a list of fields assumed to be
              separated in the file by a delimiter character (see -d); for
              example, -fl,7 copies the first and seventh field only.  Lines
              with no field delimiters will be passed through intact (useful
              for table subheadings), unless -s is specified.

    -d char   The character following -d is the field delimiter (-f flag
              only).  Default is tab.  Space or other characters with special
              meaning to the shell must be quoted.

    -s        Suppresses lines with no delimiter characters in case of -f
              flag.  Unless specified, lines with no delimiters will be passed
              through untouched.

  DESCRIPTION

    The cut command cuts out columns from a table or fields from each line of
    a file; in database parlance, it implements the projection of a relation.
    The fields as specified by list can be fixed-length, that is, character
    positions as on a punched card (-c flag) or the length can vary from line
    to line and be marked with a field delimiter character like tab (-f flag).
    The cut command can be used as a filter; if no files are given, stdin is
    used.  In addition, a filename of `` - '' explicitly refers to stdin.

    Either the -c or -f flag must be specified.

    Use grep to make horizontal ``cuts'' (by context) through a file, or paste
    to put files together column-wise (that is, horizontally).  To reorder
    columns in a table, use cut and paste.




  2/94 - Intergraph Corporation                                              1






  cut(1)                              CLIX                              cut(1)



  EXAMPLES

    1.  To map user IDs to names:

        cut -d: -f1,5 /etc/passwd


    2.  To set name to current login name:

        name=`who am i|cut -fl -d" "`


  DIAGNOSTICS

    ERROR: line too long
           A line can have no more than 1023 characters or fields, or there is
           no newline character.

    ERROR: bad list for c/f option
           Missing - c or -f flag or incorrectly specified list.  No error
           occurs if a line has fewer fields than the list calls for.

    ERROR: no fields
           The list is empty.

    ERROR: no delimiter
           Missing char on -d flag.

    ERROR: cannot handle multiple adjacent backspaces
           Adjacent backspaces cannot be processed correctly.

    WARNING: cannot open <filename>
           Either filename cannot be read or does not exist.  If multiple
           filenames are present, processing continues.

  EXIT VALUES

    The cut command will exit with a value greater than 0 if a problem is
    encountered.

  RELATED INFORMATION

    Commands: grep(1), paste(1)











  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026