command function : Cut files, cut files in units of behavior or in bytes
command Syntax :
- Split [–help][–version]
- Split [-< number of rows >][-l < rows;] [file to be cut] [output FILENAME]
, in number of rows
- Split [-B < bytes >][-c < bytes;] [file to be cut] [output file name], in bytes
The output file name refers to a file that is then prefixed with the cut.
1. Cutting files in a behavioral unit
- First create a 5-line file Hello,
#cat helloHello, World1Hello, World2Hello, World3Hello, World4Hello, World5
#split -2 hello split1_
- The split command cuts the file in two units, each consisting of a new file, and 5 rows with three files, each with the following names:
2. Cut in bytes
Or the file hello, using the command ls-l hello can see the size of the file is 65 bytes, cut the file with 10 bytes, there will be 7 files
Use the-B command first, as follows:
#split -b 10 hello split2_
- There are 7 files cut out,
split2_aa , split2_ab , split2_ac , split2_ad , split2_ae , split2_af , split2_ag
- The following uses the-c parameter, as follows:
#split -C 10 hello split3_
Cut out 10 files and output the following with the Ls-l command:
Although the file is also cut in bytes, but the-C parameter will try to maintain the integrity of each line, that is, a row has 13 bytes, then it will be cut into two files, a 10 byte, a 3 byte, and the-B parameter will accumulate 8 bytes to the next line to fill 10 bytes and then cut, so-b parameter only 7 files, The-c parameter has 10 files.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Linux command-File management class" Split command