I'd like to split the contents of a .txt file into multiple files, but I'm encountering two questions about limitations of csplit:
(1) can anyone offer a way around csplit's maximum limit of '99' file splits? I have a file with up to 384 splits based on a recurring blank line or character. I'd like csplit to be able to accomodate this with {*}, but this exceeds csplit's intrinsic file generation capacity.
(2) does anyone know of a way to pass the contents of a file to csplit (pipe to csplit), or can csplit only be used in its conventional way of calling a file in place? i.e. csplit -f split_name file_to_split.txt /split/ {*}
vs. [series of commands] | csplit -f split_name /split/ {*}
Thank you for any suggestions, or alternatives to accomplish a similar task.
-b '%03d'
?csplit
reads from stdin too, check your man page:If file is a dash ('-'), csplit reads from standard input.
You can getgnu coreutils
on mac via homebrew, google for more details.csplit
doesn't have{*}
at all, but it does have the POSIX-n
option,Use number decimal digits to form filenames for the file pieces
, which I just tested and it seems to work when you give the appropriate repetition count.