Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cut(1) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

grep

paste

cut

PURPOSE

     Writes out selected fields from each line of a file.

SYNOPSIS
     cut  -clist [file1  file2  ...]
     cut  -flist [-dchar] [-s] [file1 file2 ...]


DESCRIPTION

     The cut command  cuts out columns from a  table or fields
     from  each line  of a  file and  writes these  columns or
     fields to standard output.  If you do not specify a file,
     cut reads standard input.

     You  must specify  either the  -c or  -f flag.   The list
     parameter  is  a comma-separated  and/or  minus-separated
     list of integer field numbers (in increasing order).  The
     minus separator indicates ranges.   Some sample lists are
     "1,4,7"; "1-3,8"; "-5,10" (short  for "1-5,10"); and "3-"
     (short for third through  last field).  The fields speci-
     fied by  list can  be a fixed  number of  character posi-
     tions, or  the length can vary  from line to line  and be
     marked with  a field delimiter  character, such as  a tab
     character.

     You can also use the grep command to make horizontal cuts
     through a  file and  the paste command  to put  the files
     back together.  To change the  order of columns in a file
     use cut and paste.

FLAGS

     -clist  Specifies character  positions.  For  example, if
             you specify "-c1-72", cut writes out the first 72
             characters in  each line of the  file.  Note that
             there is no space between -c and list.
     -dchar  Uses the specified character  as the field delim-
             iter  when you  specify  the -f  flag.  You  must
             quote  characters  with  special meaning  to  the
             shell, such as the space character.
     -flist  Specifies a  list of  fields assumed to  be sepa-
             rated in  the file  by a delimiter  character, by
             default the  tab character.  For example,  if you
             specify "-f1,7",  cut writes  out only  the first
             and seventh fields of each  line.  If a line con-
             tains  no  field   delimiters,  cut  passes  them

             through  intact (useful  for table  subheadings),
             unless you specify the -s flag.
     -s      Suppresses  lines that  do not  contain delimiter
             characters (use only with the -f flag).

EXAMPLE

     To display several fields of each line of a file:

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

     This displays the login name and full user name fields of
     the system password file.  These  are the first and fifth
     fields ("-f1,5") separated by colons ("-d:").

     So, if the /etc/passwd file looks like this:

       su:UHuj9Pgdvz0J":0:0:User with special privileges:/:/bin/sh
       daemon:*:1:1::/etc:
       bin:*:2:2::/bin:
       sys:*:3:3::/usr/src:
       adm:*:4:4:System Administrator:/usr/adm:/bin/sh
       pierre:boodwqT3irHFE:200:200:Pierre Harper:/u/pierre:/bin/sh
       joan:wijBNaYpCZuL.:202:200:Joan Brown:/u/joan:/bin/sh

     then cut produces:

       su:User with special privileges
       daemon:
       bin:
       sys:
       adm:System Administrator
       pierre:Pierre Harper
       joan:Joan Brown

RELATED INFORMATION

     The following commands:  "grep" and "paste."

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