To split large files into small pieces, we use the split command in the Linux operating system.The split command is used to split or break large files into small pieces in the Linux system. By default, it generates output files of a fixed size, the default lines are 1000 and the default prefix would be ‘x’.
For example, if the output file is not given, the default filename would be xaa, xab, etc. When a – (hyphen) is used instead of an input file then the data is derived from standard input.
The general syntax of the split command as follows.
split [OPTION]... [FILE [PREFIX]]
Brief description of options available in the split command.
|Sr.No.||Option & Description|
Generate suffixes of length N, the default length is 2.
Append an addition suffix to the filenames.
Put SIZE bytes per output file.
Put at most SIZE bytes of records per output file.
Use numeric suffixes starting at 0 instead of by default alphabetic.
Use hex suffixes starting at 0, not alphabetic.
Same as -x option, but allow to set the start value.
Do not generate empty files with -n option.
Write to shell command, and the file name is $FILE
Put NUMBER lines/records per output file.
Display this help and exit
Output version information and exit
To break or split a large file into small pieces, we use the split command in the Linux system as shown below.
$ split text.txt
After executing the above command, the file text.txt will be broken into two pieces xaa and xab in our file system.
To split large files into small pieces, we use the -l option with the split command in the Linux system as shown below.
Suppose we want to split a file into four pieces based on line then, we have to execute the below command.
$ split -l 4 text.txt
To split a file into small pieces and print what is being done, we use the --verbose option with the split command in the Linux system.
$ split --verbose text.txt Creating file ‘xaa’ Creating file ‘xab’
To check more information and option with descriptions about the split command, we use the --help option with the split command as shown below.
$ split --help
To check in which version the split command is working, we use the --version option with the split command in the Linux system as shown below.
$ split --version