Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the split command that breaks files into pieces –according to your instructions if you like — and gives the pieces sequential names. As a first example, we’ll take this large file and split it using the default settings.
$ split mybigfile
While we don’t immediately see that something was done, listing our files by age (newest last) will show us that some files were just created:
The split command has broken the content of mybigfile into a large number of 1,000 line files while leaving the original file intact and given them names like xaa and xab.
If you prefer to see what the command is doing, you can run it with the –verbose option:
You can elect to split files into pieces based on the number of lines or the size in bytes, kilobytes, megabytes, gigabytes and so on using options like -l500 (500 lines), -b10K (10 kilobytes), -b2G (2 gigabytes), etc. You can also choose to give the new files more meaningful names by using a command like this:
The “bigfile.” part of this command specifies a prefix for the file resultant pieces.
Closing: That’s your Linux tip for the split command. If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.

Similar Posts