1. Splitting files
You can use the split
command to split files, which supports both text and binary file splitting, and the cat
command to merge files.
1.1 Text file splitting
When splitting a text file, you can split it by file size or by number of lines of text.
Splitting by file size
When splitting a file by file size, you need to specify the split file size with the -C
parameter.
|
|
As shown above, we split the large file large_file.txt
by 100M
size and specify the split file prefix stxt
; when no prefix is specified, split
will automatically name the split file, usually starting with x
.
Split by line
Text files can also be split by lines. When splitting by lines, the file size is ignored and the number of lines in the split file is specified with the -l
argument.
|
|
1.2 Binary file splitting
Splitting a binary file is similar to splitting a text file by size, except that the -b
argument specifies the size of the split file.
|
|
2. File merging
You can use the cat
command to merge files that are split in the above ways.
The cat
command merges split files.
|
|
3. Command Format
3.1 split
command description
The split
command has the following format.
|
|
Command parameters
|
|
3.2 cat
command description
Common usage scenarios for the cat
command are
Displaying the contents of a file.
|
|
Create an empty file.
|
|
File merge.
|
|