Skip to content

Instantly share code, notes, and snippets.

@TimJDFletcher
Last active June 23, 2017 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimJDFletcher/6b4f81661573510ffaeb5036e8561dc0 to your computer and use it in GitHub Desktop.
Save TimJDFletcher/6b4f81661573510ffaeb5036e8561dc0 to your computer and use it in GitHub Desktop.
Simple bash script to loop over a multi layered gzip file
#!/bin/bash
set -e
maxloop=100
loop=0
file="$1"
while file "${file}" | grep -q "gzip compressed data" ; do
temp=$(mktemp)
gzip -dc "${file}" > ${temp}
mv ${temp} "${file}"
loop=$((loop+1))
if [ $loop -gt $maxloop ] ; then
Failed to uncompress file after $loop loops
exit 1
fi
done
echo decompressed $file after $loop loops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment