home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: cu Chapter 2
UNIX Commands
Next: Reference: cxref
 

cut



cut

 

options

 [

files

]

Select a list of columns or fields from one or more files . Option -c or -f must be specified. list is a sequence of integers. Use a comma between separate values and a hyphen to specify a range (e.g., 1-10,15,20 or 50-). See also paste , join , and newform .

Options

-c list

Cut the column positions identified in list .

-d c

Use with -f to specify field delimiter as character c (default is tab); special characters (e.g., a space) must be quoted.

-f list

Cut the fields identified in list .

-s

Use with -f to suppress lines without delimiters.

Examples

Extract usernames and real names from /etc/passwd :



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

Find out who is logged on, but list only login names:



who | cut -d" " -f1

Cut characters in the fourth column of file , and paste them back as the first column in the same file:



cut -c4 



file

 | 
paste
 - 

file


Previous: Reference: cu UNIX in a Nutshell: System V Edition Next: Reference: cxref
Reference: cu Book Index Reference: cxref

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System