1. Command function
split splits the file into multiple fragmented files.
2. Grammar format
split option input prefix
split option input filename output filename prefix
Parameter Description
parameter |
Parameter Description |
-a |
suffix of length n, default length is 2 |
-b |
Maximum bytes of output file |
-c |
The maximum number of bytes for the number of lines of the output file |
-l |
The maximum number of lines in the output file |
-d |
Replacing letter suffixes with numeric suffixes |
3. Example of use
Example 1 Split passwd files, each file has a maximum of 8 lines, the suffix length is 3, and the suffix starts with b
[root@localhost chu]# split -l 8 -a 3 passwd b [root@localhost chu]# ls baaa baab baac passwd #The output file of the yellow part
Description: split -l 8 -a 3 passwd b
-l 8 specifies that the maximum number of lines in the output file is 8 lines; -a 3 suffix length is 3; passwd input file; b output suffix starts with b
Example 2 Split passwd files, each file has a maximum of 8 lines, the suffix length is 2, the suffix starts with b, and the suffix uses a number
[root@localhost chu]# split -l 8 -a 2 -d passwd a [root@localhost chu]# ls a00 a01 a02 passwd
Description: split -l 8 -a 2 -d passwd a
-l 8 specifies that the maximum number of lines in the output file is 8; -a 2 suffix length is 3; passwd input file; -d number suffix instead of letter suffix; a output suffix starts with a
Example 3 Split files by size
[root@localhost chu]# split -b 200 -d passwd b [root@localhost chu]# ls b00 b01 b02 b03 b04 b05 passwd [root@localhost chu]# more b00 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/