Split File

You are here:
< All Topics

I’ve never found a utility in Linux for splitting a file based on a set of key columns in a text file, and for years I’d just script a little something or use a text editor. Maybe there is a utility commonly found in repos for doing it and I’m just missing it, but if that is the case, it needs a new name or something for oddballs like me who aren’t catching on. Anyway, I finally got tired of making one-off solutions for doing it, and just took a day and wrote one. It has a number of alternative ways for specifying the columns to use as the key string to split on. It can also split on a record delimiter. There’s a README.

Note that (when not in record mode) the file likely needs to have its lines grouped by key values to get what you want out of it. You can do that easily with a sort, unless you have a special and unusual use case.

Source code is here: https://sourceforge.net/p/splitfile/

Table of Contents