Instantly share code, notes, and snippets.

Embed
What would you like to do?
split one text file into many

if you want to split one text (or html or similar) file into many, here's a trick:

split -p '^plop' file.txt newfile-

...will split file.txt whenever a line starts with 'plop', into files with names like newfile-a, newfile-b, newfile-c, and so on...

I'd love to get it to create numbered files, instead of lettering them a, b, c for extra credit, I'd love to change the filename to be the first line of text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment