Shell -- cut usage,
Cut is a processing object for each row. This mechanism is the same as sed.
Cut accepts three positioning methods:
1) byte:-B
2) characters:-c
3) fields:-d
Eg: extract the 3, 4, 9 Bytes: cut-B 3-5, 9
Note: If you use the-B Option for the cut command, all the positions after-B are sorted from small to large before extraction. The order cannot be reversed.
-3 indicates from the first byte to the third byte;
3-indicates from the third byte to the end.
For Chinese extraction,-c is measured in characters and the output is normal.-B is calculated in bytes (8-bit binary.
If you encounter multi-byte characters, use the-n option to remove the multi-byte characters. Cut-nb 1, 2, 3
For non-fixed format information, the domain is required. You need to set the delimiter before extracting the nth domain.
Cut-d:-f 1
-D: Set the delimiter to-f 1 to extract the first domain.
Note: How can I identify spaces and tabs?
First, check whether the space consists of spaces or tabs:
Cat tab_space.txt
Sed-n l tab_space, txt
If it is a TAB, \ t is displayed. If it is a space, it is displayed as is. (L after n in sed is lower case L)
What symbols does cut-d use to represent tabs or spaces?
The default cut-d interval is tab, which can be omitted. If space is set as the delimiter, cut-d ''-f 4
(There must be a space in two single quotes)
In addition, only one space can be set after-d, and multiple spaces are not allowed. The delimiter allowed by cut is a character.
Reference: http://blog.sina.con/cn/s/blog_5e77c61f0100hqky.html