- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to split or break large files into pieces in Linux?
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
- How we can split Python class into multiple files?
- How to Empty or Delete a Large File Content in Linux?
- How to stream large .mp4 files in HTML5?
- How to copy a file, group of files, or directory in Linux?
- How to download large files through PHP script?
- How to Handle Large CSV files with Pandas?
- How to upload large files above 500MB in PHP?
- How we can compress large Python files?
- Sending large files over internet
- How to Find a Specific String or Word in Files and Directories in Linux
- How to create links between files in the Linux?
- How to sort lines of text files in Linux?
- 8085 program to separate (or split) a byte into two nibbles
- How to Protect Files and Directories from Deleting in Linux