Split,csplit command: file cutting
Split and csplit are two methods of file cutting.
Split
Common options:
-b: cut in block size, commonly used units are k (kb), M (MB), G (GB)
Example: split-b 10k server.log cuts the contents of the original file into a file every 10k
-l: cut in rows
Example: split-l 8 server.log cuts the contents of the original file into a file every 8 lines
-d: the cut files are distinguished by numbers, for example, the file name of the split file is 01j02j03,
For example, if split-l 8 server.log-d does not specify a prefix, the default cut file is x00menx01recoverx02
-a: indicates the number of digits of the file number generated after the file is cut
Example: split-L8 server.log-d-a 4 the file number generated after cutting starts with 0000
PREFIX: add the specified prefix, only at the end of the command
Example: split-l8 server.log-d-a 4 test is cut to generate a file with the suffix test
Csplit: you can use the specified content as a cutting condition
# csplit server.log / SERVER/-n 2-s {*}-f server-b "d.log"
Common options:
/ SERVER/: specifies the conditions for cutting, where SERVER is used as the keyword, that is, cutting is performed only when SERVER appears in the current line
-n: specify the length of the file number after cutting; (for example,-n 2, indicating the cut file number 001.01)
-s: use the command to enter silent mode without printing other information
{*}: specify the number of cuts from top to bottom. * means to repeat the cutting until the end of the file. When * is a number, it means several cuts.
-f: specifies the prefix of the file after cutting
-b: specify the suffix of the file after cutting
D.log: indicates that the sliced file is 00.logjor 01.log