How to use split Linux command to split a file into pieces

Have you ever wanted to split a large file into multiple smaller files? For example, a 10Gb log file, we need to divide it into multiple small files, so that we can read it using a normal text editor. Sometimes we need to transfer a large file of 20Gb to another server, which requires us to split it into multiple files to facilitate data transfer. Let us how to use split Linux command to split a file into pieces.

Use

Example

1. Split 1000 lines per file
The split command splits files into 1000 lines per file, and the file names are [prefix]aa, [prefix]ab, [prefix]ac, etc., the default prefix is ​​a, and the number of lines in each file is 1000.

2. Split 20Mb per file

Split the file into multiple 20MB files with the -b option command as follows:

split -b 20M dpkg.log

3. Split 50MB per file with a specified prefix for each file

Use the –bytes option to split the file into multiple 50MB files. The –bytes option is similar to the -b option. Specify the prefix in the second parameter.

split –bytes=50M dpkg.log dpkg_attack

4. Split file based on number of lines

Use the -l option to specify the number of lines to split the file into multiple files with the same number of lines.

Support Our Threat Intelligence

If you find our technology report and cybersecurity news helpful, consider supporting our work.

Crypto QR Code
USDT (TRC20):
TN8BdV8cp4T1Cd28gK9qTAnZknzzuwyUtm
USDT (ERC20):
0x3725e1a7d3bc5765499fa6aaafe307fabcd75bce