1

This question already has an answer here:

Is there a way to give custom filenames for split command? I am splitting a file that is 100GB into chunks of 128MB. Here is what I am doing

split -b 128000k mydata.csv.

This creates files with following names xaa,xab,xac,.. etc. I am wondering if it is possible to have custom names like mydata_0.csv, mydata_1.csv for each of the splits.

marked as duplicate by user34720, don_crissti, Jeff Schaller, mdpc, GAD3R Jan 18 '17 at 21:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

Yes, with GNU split you can achieve this:

split -d -a3 -b 128M --additional-suffix=.csv mydata.csv mydata_

Explanation:

  • -d -a3: use a numerical index with 3 digits
  • -b 128M: split in 128 MB chunks
  • --additional-suffix=.csv: add a .csv extension
  • the trailing mydata_ is the prefix
  • 1
    in centos, I get split: unrecognized option '--additional-suffix=.csv' – brain storm Jan 18 '17 at 18:28
  • @brainstorm The option was added to GNU split in 2012. split --version yields me 8.21. If your version is not GNU or too old, see this answer – xhienne Jan 18 '17 at 18:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.