Last active
June 23, 2017 10:28
-
-
Save TimJDFletcher/6b4f81661573510ffaeb5036e8561dc0 to your computer and use it in GitHub Desktop.
Simple bash script to loop over a multi layered gzip file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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