split a big file

Cut a big file into smaller pieces, by lines or by size, and join them again.

  • files
  • text

Steps

  1. split -l 1000 big.txt part_

    pieces of 1,000 lines: part_aa, part_ab…

  2. split -b 100M big.bin part_

    pieces of 100 MB

  3. split -n 4 big.txt part_

    four pieces of equal size (GNU)

  4. split -d -l 1000 --additional-suffix=.csv big.csv part_

    numbered pieces that keep the .csv ending (GNU)

  5. cat part_* > big.txt

    join them again

Notes

  • A CSV's header line goes only into the first piece.

Commands used

  • split
  • cat
  • csplit

Each has a page in lore: lore split opens it.