Overview
split divides the input file into multiple output files based on a specified size (in bytes) or number of lines. By default, output filenames are generated as 'xaa', 'xab', 'xac', etc., which can be changed using suffix options.
Key Features
- Split files by specified byte size
- Split files by specified number of lines
- Customize output filename suffixes (numeric, length, additional suffix)
- Easily recombine split files
Main Options
The main options of the split command control the criteria for splitting files and the naming convention of the output files.
Splitting Criteria
Output Filenames
Comando generado:
Combina los comandos.
Descripción:
`split` Ejecutando el comando.
Combina las opciones anteriores para ejecutar virtualmente los comandos junto con la IA.
Usage Examples
Learn how to effectively split files through various usage examples of the split command.
Split file into 10MB chunks
split -b 10M large_file.txt output_prefix_
Splits large_file.txt into files of 10MB each, creating filenames starting with 'output_prefix_' (e.g., output_prefix_aa, output_prefix_ab).
Split file into 1000 lines per file
split -l 1000 large_log.txt log_part_
Splits large_log.txt into files with 1000 lines each, creating filenames starting with 'log_part_'.
Split into 500MB chunks with numeric suffix
split -b 500M -d video.mp4 video_part_
Splits video.mp4 into 500MB chunks, using numeric suffixes (00, 01, etc.) in the filenames. The default suffix length is 2.
Split into 1GB chunks with suffix length 3
split -b 1G -d -a 3 archive.tar archive_part_
Splits archive.tar into 1GB chunks, specifying a suffix length of 3 to generate filenames like 'archive_part_000', 'archive_part_001', etc.
Recombine split files
cat output_prefix_* > large_file.txt
Recombines the previously split files starting with 'output_prefix_' back into the original large_file.txt.
Tips & Precautions
Useful tips and points to note when using the split command.
Recombining Files
Split files can be easily recombined using the `cat` command. For example, use `cat prefix_* > original_file`. The order of the wildcard (`*`) is important, so it's advisable to check with `ls` to ensure they are combined in the correct sequence.
- Use the `cat` command for recombination
- Pay attention to file order when using wildcards (`*`) (files are sorted alphabetically/numerically)
Disk Space
When splitting files, both the original file and the split files exist simultaneously, so sufficient disk space is required. If you plan to delete the original file after the split operation, you need to secure space in advance.
- More than double the original file size in disk space is needed for the split operation
- Clean up unnecessary files after the operation
Suffix Length
If you expect a large number of files to be created, it's recommended to use the `-a` option to specify a sufficiently long suffix length. For instance, if more than 100 files are generated, using `-a 3` allows for suffixes from '000' to '999'.
- Adjust suffix length with the `-a` option based on the number of split files
- The default suffix length (2) can create up to 676 files (aa-zz)