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 a4e4100 commit eb0f78f
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 @@ -85,7 +85,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 eb0f78f

Please sign in to comment.