Comments on Linux Csplit Command Explained for Beginners (6 Examples)
While working on the command line in Linux, you may find yourself in situations where-in you need to split a file into multiple parts. If you are already looking for a way to do this, or simply want to know how this can be done, you'll be glad to know there exists a tool - dubbed csplit - that's built for this purpose.
2 Comment(s)
Comments
thanks for this! it works but maxes out at 100 files. If I have a spreadsheet that has 700--or 7000--lines, can this be adapted so that it will create 700--or 7000--new files?
Are you on a Mac? I had this same issue and had to install coreutils to get the gcsplit command instead. That one works with a * as the repeat argument.
You might not need all of these, you figure it out
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt
This is the command I ended up with:
gcsplit -b "%04d.txt" -f "" masterfile.tosplit /},/1 {*}