|
Cut command is one of the most commonly used commands Linux.
As its name suggests, cut job is to "cut", specifically, is in charge of cutting data in a file. cut each act is a processing target, and sed this mechanism is the same.
Cut cut metric command in three ways:
Byte Cut: -b (byte)
Cut by character: -c (character)
By Shear: -f (field) to specify the time domain by shear delimiter, the default delimiter is a tab (\ t).
In addition, cut command also supports a range of digital representation,
N N'th byte, character or field, counted from 1
N- from N'th byte, character or field, to end of line
N-M from N'th to M'th (included) byte, character or field
-M From first to M'th (included) byte, character or field
Examples given to illustrate:
Cut in bytes
date | cut -b 1-5
2014
date | cut -b 1-6
2014
date | cut -b 1-7
Year 2014
As can be seen from the above example the Chinese character "years" accounted for 3 bytes
In accordance with the character cut
date
October 10, 2014 Friday 14:48:16 CST
date | cut -c 1,3,4
214
Positioning a plurality of separated by commas
In accordance with Shear
date
October 10, 2014 Friday 14:46:09 CST
date | cut -d "" -f 4,5
Friday 14:46:12
-d delimiter and indicates delimiter must be a single character. |
|
|
|