How to use split to cut and merge files under Linux
This article mainly introduces how to use split to cut files and merge files under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Split uses split: you can split a large file into many small files, and sometimes you need to split the file into smaller fragments, such as generating logs to improve readability
Syntax: split (option) (file) PREFIX
Options:
-b: the value is the size of each output file, in byte.
-C: the maximum number of byte per line in each output file.
-d: use numbers as suffixes.
-l: the value is the number of columns per output file.
PREFIX: stands for the leading character and can be used as the leading file of the cutting file.
Example:
1) there is an 11m logs that needs to be cut into 1m files
Split-b 1m logs
2) the file is divided into multiple suffix files with letters. If you want to use a numeric suffix, you can use the-d parameter, and you can use-a length to specify the suffix length:
Split-b 1m logs-d-a 2
3) specify the prefix of the file name for the split file:
Split-b 1m logs-d-a 2 file_split
4) use the-l option to split the file according to the number of lines of the file, for example, to split the file into small files containing 100 lines each
Split-l 100 logs
5) after the file is cut and moved to the corresponding directory, you need to merge the file to get the original file (PS: verify md5 for transferring files)
Cat x * > log diff-r log logs
No output after diff, indicating that the two files are consistent
Thank you for reading this article carefully. I hope the article "how to use split to cut and merge files under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!