Linux Split command
Function Description: Cutting file.
Syntax: Split [--help][--version][-< rows >][-b < bytes >][-c < bytes >][-l < lines >][files to cut [output FILENAME]
Add: Split can cut the file into smaller files, preset every 1000 lines cut into a small file.
Parameters
-< number of rows > or-l< > Specifies how many rows to cut into a small file.
-b< bytes > Specifies how many words will be cut into a small file. Support Unit: M,k
The-c< byte > is similar to the-B parameter, but as much as possible to maintain the integrity of each row while cutting.
--help display Help.
--version Displays version information.
[Output file name] Sets the file's predecessor file name after the cut, and split automatically adds the number after the previous file name.
File segmentation with split under Linux:
Mode One: Specifies the number of rows after the split file
For a text file, you can split the file by specifying the number of rows in the split file.
Command: Split-l large_file.log new_file_prefix
Mode two: Specify File size after split
The code is as follows |
Copy Code |
Split-b 10m Server.log Server_prefix |
We can also separate files by file size for binary files.
Split file file.tar.gz into a file with "File_" as the filename prefix with a size of 10M
The code is as follows |
Copy Code |
$split-B 10m file.tar.gz File_ |
File merging with cat under Linux:
Command: Cat small_files* > Large_file
Merging a split file
The code is as follows |
Copy Code |
$cat file_* > file.tar.gz |