Linux Views 4

The Linux cut command

The Linux cut command image 1

 

The cut command shows only a given part of a text file or of piped output.

※If you specify a separate delimiter (for example a colon (:) or a semicolon (;)), it is displayed using that delimiter as the basis.

cut [option] [file]

 Option Description 
-b  Shows output in byte units
-c  Shows output in character units
-d  Uses the given delimiter instead of the default field delimiter, tab.
-f  Builds and shows only the given fields
-s  Does not show lines that do not contain the field delimiter

※With the -b, -c, and -f options you can specify a numeric range as follows

Category  Description 
 A   The Ath 
 A-  From the Ath onward
 A-B  From A through B
 -B  Through B

Command examples

Contents stored in the taucl file

The Linux cut command image 2

Print the 3rd in byte units

The Linux cut command image 3

Print the 3rd in character units

The Linux cut command image 4

Print the 3rd field using ( : ) as the delimiter

The Linux cut command image 5

When the field has no delimiter

The Linux cut command image 6

With the -s option, print without showing lines that do not contain the field delimiter

The Linux cut command image 7

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.