Although I have found many many cases where one can use the split
command to split a file into parts, I wasn't lucky enough to find a way to use split
to massively split a group of files.
For example I have a folder and inside this folder are hundreds of files that start with the character "a" and end with ".txt". How can I get split
with one line of code to split all of these files, say into parts with at most 20 lines of text? Something like:
split -l 20 a*.txt
does not work because split
gives an
extra operand "filename" error.
Thanks
This will do the job:
Run the above command from within the directory that contains the files you want to split. It will:
a
.I mostly use split in scenario where I want later splitted parts to merge together again. In situation like you describe, I can't imagine, how you could later them merge into original files. So, if in your situation merging back again is not relevant, I think this simple command could be sufficent: