Cut by size, 100M per cut
Split-b 100m filename
Cut by line number, cut every 100w line, and bring forward prefix
split-l10000000 Pc.txt I_
Merging: Cat x* > Pc.txt
Split: Cutting Files
Syntax: Split [--help][--version][-b < bytes >][-c < bytes >][-l < rows >][files to be cut] [output FILENAME]
Supplementary note: Split can cut the file into smaller files, preset every 1000 lines cut into a small file
Parameters
-l< line > Specify how many lines to cut into a small file
-b< bytes > Specifies how many words will be cut into a small file. Support Unit: M,k
-c< byte > is similar to the-b parameter, but try to maintain the integrity of each line while cutting
? Help Display assistance
? version display release information
[Output FILENAME] Sets the file's predecessor file name after the cut, and split automatically adds a number to the previous file name
Instance 1, split by 1000 rows per file
The split command splits the file into 1000 lines per file, and the filename is prefixed by prefix]aa, [prefix]ab, [prefix]AC, etc., the default prefix is x, the number of rows per file is 1000 lines, and the command is as follows:
$ split mylog
$ wc-l *
4450 mylog
1000 xaa
1000 xab 1000 xac
1000 Xad
450 xae
Instance 2, 20MB segmentation per file
Split file for multiple 20MB files with the-B option command as follows:
$ split-b 20M logdata
$ ls-lh | tail-n +2
-RW-------1 sathiya sathiya 102M June 18:47 logdata-RW
------- 1 Sathiya sathiya 20M 19:20 xaa
-rw-------1 sathiya sathiya 20M 19:20 xab-rw
-------1 Sathiya s Athiya 20M June 19:20 xac
-rw-------1 sathiya sathiya 20M June 19:20 xad
-rw-------1 Sathiya Sathiya 20M June 19:20 xae
-rw-------1 sathiya sathiya 1.6M June 19:20 Xaf
Instance 3, specifying prefix segmentation with each file 50MB
Use the--bytes option to split the file into multiple 50MB files,--bytes similar to-B option, and specify a prefix in the second argument.
$ split--bytes=50m logdata mydatafile
$ ls-lh Total
204M
-rw-------1 sathiya sathiya 102M June 18:47 Logd ATA
-rw-------1 sathiya sathiya 50M June 19:23 MYDATAFILEAA
-rw-------1 sathiya sathiya 50M June 19:23 MyD Atafileab
-rw-------1 sathiya sathiya 1.6M 19:23 MYDATAFILEAC
Instance 4, split file based on row number
Use the-l option to specify the number of rows to split the file into files with the same number of rows.
$ wc-l testfile
2591 testfile
$ split-l 1500 testfile importantlog
$ wc-l *
1500 importantlogaa
1091 importantlogab
2591 testfile
Instance 5, naming the split file with a numeric suffix
Use the-D option to specify that the suffix is a number, such as 00,01,02 ... rather than AA,AB,AC.
$ split-d testfile
$ ls
testfile x00 x01 x02
Available options
Short option long option option description
-B--bytes=size The size value is a byte for each output file.
-C--line-bytes=size The maximum byte of a single line in each output file.
-D--numeric-suffixes uses numbers as the suffix.
The-l--lines=number number value is the size of the column per output file.
How to use Cat in combination
Cat command
Syntax: Cat [-ABEENSTTUV] [--help] [--version] FileName
-N or? Number numbering the number of rows for all outputs starting with 1
-B or? Number-nonblank and-n are similar except for blank lines not numbered
-S or? Squeeze-blank a blank line that is substituted for one row when a blank line with two consecutive lines is encountered
-V or? show-nonprinting
#cat常用功能
#一次显示整个文件
Cat filename
#创建一个文件, you can only create new files, you cannot edit existing files
cat > FileName
#将几个文件合并为一个文件.
cat file1 file2 > file
So the above example merges the split file to use:
#合并
cat a.tar.gz.* > a.tar.gz
#合并并解压
cat a.tar.gz.* | tar-zxv