Skip to content

Commit

Permalink
improve gz function
Browse files Browse the repository at this point in the history
  • Loading branch information
Okeanos committed Apr 10, 2023
1 parent 54802bc commit b32e841
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stow/shell/dot-functions
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ function server() {
# Compare original and gzipped file size
function gz() {
local origsize gzipsize ratio
origsize=$(wc -c <"${1}")
origsize=$(
stat -Lf"%z" -- "${1}" 2> /dev/null; # macOS `stat`
stat -Lc"%s" -- "${1}" 2> /dev/null; # GNU `stat`
)
gzipsize=$(gzip -c "${1}" | wc -c)
ratio=$(echo "${gzipsize} * 100 / ${origsize}" | bc -l)
printf "orig: %d bytes\n" "${origsize}"
Expand Down

0 comments on commit b32e841

Please sign in to comment.