Linux file segmentation and combination

Files in Linux, especially log files, are too large to open, or if you want to put the file on a carrier with a file size limit, you can use the split command to cut into small files

File split

There are two ways to split the command:

  • Specify the number of rows to cut
split -l 300 log.txt newfile

300 lines per file

  • Specify file size to cut
split -b 500m log.txt newfile

The size of each file is 500m. The file name of the new file generated is newfile followed by aa, ab, ac...... For
example, the log.txt file has 1.4G, then 3 files will be cut out, the file names are respectively newfileaa, newfileab, newfileac, no extension The
new file name does not need to be set, the system defaults that the new file starts with the letter x, that is, if the command is:

split -b 500m log.txt

Then the file name is xaa, xab, axc

In addition, the cut files can be combined again, the command is:

File combination:

cat newfile* > orifile

Guess you like

Origin blog.csdn.net/yao_zhuang/article/details/109170027