cut-removes selected fields or characters from each line of a file

 <  Day Day Up  >  

cut ” removes selected fields or characters from each line of a file

 cut clist [ filename ... ] cut flist [ dc ] [ s ] [ filename ... ] 

The cut command cuts out columns or characters from a line of a file; if no files are given, uses standard input. The “d option specifies the field delimiter. The default delimiter is a tab.

Example A.17.
 1   cut -d: -f1,3 /etc/passwd 2   cut -d: -f1-5 /etc/passwd 3   cut -c1-3,8-12 /etc/passwd 4   date  cut -c1-3 

EXPLANATION

  1. Using the colon as a field delimiter, displays fields 1 and 3 of the /etc/passwd file.

  2. Using the colon as a field separator, displays fields 1 through 5 of the etc/passwd file.

  3. Cuts and displays characters 1 through 3 and 8 through 12 of each line from the /etc/passwd file.

  4. Sends the output of the date command as input to cut . The first three characters are printed.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net