I have a big .gz file, which is 2.6 GB in itself. I cannot uncompress it due to size limitation. The file is a single large text file. I am not being able to decompress it completely due to size limitation. I want to split it into say 10 individual parts and decompress each one individually so that I can use each individual files:My questions are:Is that possible ?Also, as part of the answer, if the commands can also be provided as I am not very well versed in these commandsThanks
Split gz file and decompress individually
gzip
The gzip compression format supports decompressing a file that has been concatenated from several smaller compressed files (the decompressed file will then contain the concatenated decompressed data), but it doesn't support decompressing a cut up compressed file.Assuming you would want to end up with a slice of the decompressed data, you may work around this by feeding the decompressed data into dd several times, each time selecting a different slice of the decompressed data to save to a file and discarding the rest.Here I'm using a tiny example text file. I'm repeatedly decompressing it (which will take a bit of time for large files), and each time I pick a 8 byte slice out of the decompressed data.  You would do the same, but use a much larger value for bs (block size).$ cat filehelloworld123ABC$ gzip -f file   # using -f to force compression here, since the example is so small$ gunzip -c file.gz | dd skip=0 bs=8 count=1 of=fragment1+0 records in1+0 records out8 bytes transferred in 0.007 secs (1063 bytes/sec)$ cat fragmenthellowo$ gunzip -c file.gz | dd skip=1 bs=8 count=1 of=fragment1+0 records in1+0 records out8 bytes transferred in 0.000 secs (19560 bytes/sec)$ cat fragmentrld12(etc.)Use a bs setting that is about a tenth of the uncompressed file size, and in each iteration increase skip from 0 by one.UPDATE: The user wanted to count the number of lines in the uncompressed data (see comments attached to the question).  This is easily accomplished without having to store any part of the uncompressed data to disk:$ gunzip -c file.gz | wc -lgunzip -c will decompress the file and write the uncompressed data to standard output.  The wc utility with the -l flag will read from this stream and count the number of lines read.