Bash: cooler gz function.
This commit is contained in:
parent
985ad2debc
commit
170be184e2
@ -13,12 +13,13 @@ function f() {
|
|||||||
find . -name "$1" 2>/dev/null
|
find . -name "$1" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get gzipped file size
|
# Compare original and gzipped file size
|
||||||
function gz() {
|
function gz() {
|
||||||
echo "Original size (bytes): "
|
local origsize=$(wc -c < "$1")
|
||||||
cat "$1" | wc -c
|
local gzipsize=$(gzip -c "$1" | wc -c)
|
||||||
echo "Gzipped size (bytes): "
|
local ratio=$(echo "$gzipsize * 100/ $origsize" | bc -l)
|
||||||
gzip -c "$1" | wc -c
|
printf "Original: %d bytes\n" "$origsize"
|
||||||
|
printf "Gzipped: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
|
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
|
||||||
|
Loading…
Reference in New Issue
Block a user