summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-05-10 20:37:27 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-05-10 20:37:27 +0100
commit738920c1dd8bbf4ab7fd68777c00f8936aa4f1c7 (patch)
tree2e17689b96845fa05e003a30b7b7a1adec8956fd /scripts
parent031b738d60ca4857d128c6b1770da57e2cb7c0fe (diff)
Add script to recompress traces.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tracerepack.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/tracerepack.sh b/scripts/tracerepack.sh
new file mode 100755
index 0000000..9152b5d
--- /dev/null
+++ b/scripts/tracerepack.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Script to recompress the traces
+
+set -e
+
+for TRACE
+do
+ gzip -l "$TRACE" | sed -n '2p' | while read COMPRESSED UNCOMPRESSED RATIO FILENAME
+ do
+ gzip -dc "$TRACE" | pv -s "$UNCOMPRESSED" | gzip --best --no-name > "$TRACE.pack"
+ done
+ COMPRESSED=`stat -c %s "$TRACE"`
+ RECOMPRESSED=`stat -c %s "$TRACE.pack"`
+ echo "$COMPRESSED -> $RECOMPRESSED"
+ if [ "$RECOMPRESSED" -lt "$COMPRESSED" ]
+ then
+ touch -r "$TRACE" "$TRACE.pack"
+ mv "$TRACE.pack" "$TRACE"
+ else
+ rm "$TRACE.pack"
+ fi
+done