Last active
August 29, 2015 14:01
-
-
Save petteyg/96c71fa3c4680552f5c4 to your computer and use it in GitHub Desktop.
Compression Comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
dir=${2##/usr/share/} | |
dir=${dir%/*} | |
file=${2##*/} | |
file=${file%.*} | |
ext=${2##*.} | |
mkdir -p $1/$dir | |
cp $2 $1/$dir/$file.$ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
dir=${2##/usr/share/} | |
dir=${dir%/*} | |
file=${2##*/} | |
file=${file%.*} | |
ext=${2##*.} | |
mkdir -p $1/$dir | |
echo bzip2 -dkc $2 | xz -cz6e > $1/$dir/$file.xz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
compare() { | |
local xzlarger=0 | |
local bz2larger=0 | |
for x in $(find xz -name "*.xz"); do | |
xzsize=$(du -b $x | cut -f1) | |
dir=${x##xz/} | |
dir=${dir%/*} | |
file=${x##*/} | |
file=${file%.*} | |
ext=${x##*.} | |
bz2size=$(du -b bz2/$dir/$file.bz2 | cut -f1) | |
if [[ $[xzsize] > $[bz2size] ]]; then | |
xzlarger=$[++xzlarger] | |
else | |
bz2larger=$[++bz2larger] | |
fi | |
done | |
echo "Larger xz count: $xzlarger" | |
echo "Larger bz2 count: $bz2larger" | |
} | |
find /usr/share -type f -a -\( -wholename "/usr/share/doc/*.bz2" -o -wholename "/usr/share/man/*.bz2" -\) | xargs -n1 -P8 ./bz2bz bz2 | |
find /usr/share -type f -a -\( -wholename "/usr/share/doc/*.bz2" -o -wholename "/usr/share/man/*.bz2" -\) | xargs -n1 -P8 ./bz2xz xz | |
du -sh bz2 xz | |
compare |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment