Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Split,csplit command: file cutting

Shulou Source: shulou.com Published: 2022-06-01 06:34:13 10月03日 Update

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

Tags: File content prefix epigenetic commonly used command suffix size number condition digit information key keyword unit file name method pattern number of times top-down Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info Redmi Docker Shulou Technology