Is there a quick way to check if a gzipped file is empty, or do I have to unzip it first?example:$ touch foo$ if [ -s foo ]; then echo not empty; fi$ gzip foo$ if [ -s foo.gz ]; then echo not empty; finot empty$ wc -l foo.gz      1 foo.gz
How can I check if a gzipped file is empty?
command line;bash;gzip
gzip -l foo.gz | awk 'NR==2 {print $2}' prints the size of the uncompressed data.if LC_ALL=C gzip -l foo.gz | awk 'NR==2 {exit($2!=0)}'; then  echo foo is emptyelse  echo foo is not emptyfiAlternatively you can start uncompressing the data.if [ -n $(gunzip <foo.gz | head -c 1 | tr '\0\n' __) ]; then    echo foo is not emptyelse    echo foo is emptyfi(If your system doesn't have head -c to extract the first byte, use head -n 1 to extract the first line instead.)