Introduction
If you have not hear about split command than you are missing a lot. As command's name suggests split command helps you to split file into smaller files. split works on any file whether it is binary or text file. This is quite useful if you cannot fit entire file on storage device such as tape or you want to split large file to be able to send it via email which has file size restrictions. You can also split large text files such as log files to smaller chunks based on the number of bytes. This article will describe syntax and usage of split command.
Frequently Used Options
- -b, --bytes=SIZE
This option specifies a size of output files - -d, --numeric-suffixes
Use numeric suffixes instead of alphabetic - -n, --number=CHUNKS
generate CHUNKS output files
Split files by output size
By default if not suffix options is used the split command will split your file into files starting with x a followed by 2 alphabetical characters. For example the first file is called xaa followed by xab, xac where last file will be called xzz. This means that your limitation in this case to to split file into maximum of 676 files. ( 26x26 ). Here is how it works. Let's say for example that we have a file of size 10MB:
$ dd if=/dev/zero of=file bs=10M count=1
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.0780163 s, 134 MB/s
$ ls -lh file
-rw-rw-r-- 1 split-example split-example 10M Jan 17 15:24 file
Now we can split this file into smaller pieces of 1MB per file output by using -b option: