Search code examples
bashshellsplitunzip

stream unzip into split


I have a zip file which I want to split into multi gzip files. I don't need the actual file on disk and prefer to keep everything in memory so it will be faster. was thinking maybe:

split -C 2M -d -a 3 --filter 'gzip > $FILE.gz' <(unzip a.zip ) a_

or unzip -c a.zip | split -C 2M -d -a 3 --filter 'gzip > $FILE.gz' a_

But it gzip the output of the unzip:

Archive:  a.zip
  inflating: data.txt

And on the second option it fails

split: cannot open ‘a_’ for reading: No such file or directory

Solution

  • -c -q is the answer

    split -C 2M -d -a 3 --filter 'gzip > $FILE.gz' <(unzip -c -q a.zip ) a_