Skip to content

Instantly share code, notes, and snippets.

@troosh
Created August 16, 2018 19:34
Show Gist options
  • Select an option

  • Save troosh/0f3d8937b2d224fb569e9045cf2f4c26 to your computer and use it in GitHub Desktop.

Select an option

Save troosh/0f3d8937b2d224fb569e9045cf2f4c26 to your computer and use it in GitHub Desktop.
Script to recompressing files from *.gz to *.xz
#!/bin/bash
for f in $(find . -name \*.gz)
do
echo -n "$(dirname "$f")/$(basename "$f" .gz): .gz => .xz ... " && \
gzip -cd "$f" | xz -9 > $(dirname "$f")/$(basename "$f" .gz).xz && \
touch --reference="$f" $(dirname "$f")/$(basename "$f" .gz).xz && \
rm "$f" && \
echo "done"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment