blob: a70b936f544567f190297961c7151f2ba9646270 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
# finds optimal --min-size value for bloc
target="blc"
# remove files on exit
trap 'rm -f "$file".bloc "$file".bloc."$target"; exit 0' EXIT SIGINT SIGTERM
if [ $# -eq 0 ]; then
echo "Usage: $0 <file>"
exit 1
fi
file=$1
function try {
bloc --from-blc -i "$file" -o "$file".bloc -m "$1"
blocade -i "$file".bloc -t "$target" -o "$file".bloc."$target"
size="$(stat -c %s "$file".bloc."$target")"
}
low=5
high=100000
best=100000000000000000
while [ $low -lt $high ]; do
mid=$(((low + high) / 2))
try $mid
echo "$mid: $size"
if [ "$size" -le $best ]; then
best=$size
high=$((mid - 1))
else
low=$((mid + 1))
fi
done
|