Skip to content

Instantly share code, notes, and snippets.

@clofresh
Created December 26, 2013 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clofresh/8135633 to your computer and use it in GitHub Desktop.
Save clofresh/8135633 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Convert gzipped haproxy files to use date extensions
for f in $(ls haproxy*.gz | grep -v 2013)
do
dest="${f%.*.gz}-"$(gunzip -c $f | head -n 1 | awk '{ print $1 }' | cut -d T -f 1 | tr --delete '-')".gz"
mv "$f" "$dest"
done
# Convert and gzip the delayed files
for f in haproxy_*.1
do
dest="${f%.1}-$(head $f -n 1 | awk '{ print $1 }' | cut -d T -f 1 | tr --delete '-')"
mv "$f" "$dest"
gzip "$dest"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment