[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

The cut Command

The next program we'll look at is the cut command. This program cuts out columns or fields of input data. For example, we can tell it to print just the login name and full name from the `/etc/passwd' file. The `/etc/passwd' file has seven fields, separated by colons:

 
arnold:xyzzy:2076:10:Arnold D. Robbins:/home/arnold:/bin/bash

To get the first and fifth fields, we would use cut like this:

 
$ cut -d: -f1,5 /etc/passwd
-| root:Operator
...
-| arnold:Arnold D. Robbins
-| miriam:Miriam A. Robbins
...

With the `-c' option, cut will cut out specific characters (i.e., columns) in the input lines. This command looks like it might be useful for data filtering.



This document was generated by Jeff Bailey on December, 28 2002 using texi2html