diff options
author | Nicolas Gallagher <nicolasgallagher@gmail.com> | 2012-12-08 11:47:28 +0100 |
---|---|---|
committer | Mathias Bynens <mathias@qiwi.be> | 2012-12-08 11:48:05 +0100 |
commit | 1a68b1e968df255b0df0a6a2d3ddf0c66d7bebdc (patch) | |
tree | 3d1187ffa9290fadaf974433aa93231a134c10e5 | |
parent | 5400992ced5746627b9cfec9df08a93318822acc (diff) | |
download | dotfiles-1a68b1e968df255b0df0a6a2d3ddf0c66d7bebdc.tar.gz dotfiles-1a68b1e968df255b0df0a6a2d3ddf0c66d7bebdc.tar.bz2 dotfiles-1a68b1e968df255b0df0a6a2d3ddf0c66d7bebdc.zip |
.functions: Make `gz` more awesome
-rw-r--r-- | .functions | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -52,12 +52,13 @@ function phpserver() { php -S "${ip}:${port}" } -# Get gzipped file size +# Compare original and gzipped file size function gz() { - echo "orig size (bytes): " - cat "$1" | wc -c - echo "gzipped size (bytes): " - gzip -c "$1" | wc -c + local origsize=$(wc -c < "$1") + local gzipsize=$(gzip -c "$1" | wc -c) + local ratio=$(echo "$gzipsize * 100/ $origsize" | bc -l) + printf "orig: %d bytes\n" "$origsize" + printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio" } # Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. |