Zero sized tar.gz file found inside a tar.gz file
- by PavanM
My current directory contains a single file like this-
$ls -l
-rw-r--r-- 1 root staff 8 May 28 09:10 pavan
Now, I want to tar and gzip this file like
$tar -cvf - * 2>/dev/null |gzip -vf9 > pavan.tar.gz 2>/dev/null
(I am aware I am creating the zipped file in the same directory as the original file)
When I run the above tar/gzip commands around 20 times, a few times I observe that the final tarred and zipped file pavan.tar.gz file has a ZERO sized pavan.tar.gz file. I am not sure from where is this zero sized file coming into the archive from.
Note: I am NOT running tar/gzip commands on an already existing tar.gz file. I always make sure that the directory has only one file before running the commands
On googling, as described here, I suspected that the tar.gz being created was also part of the file being archived. But in my case, gzip is the one who's creating the final file and by the time gzip runs, tar should be done tarring.
This is happening on AIX but I've used Linux tag too, to draw more attention, as I guess the problem is platform independent.