logmanager/logcompressor

38 lines
763 B
Plaintext
Raw Permalink Normal View History

2011-02-23 15:39:35 +01:00
#!/bin/sh
p=gzip
2011-02-23 15:39:35 +01:00
help() {
cat <<EOF
Usage: `basename "$0"` -h | [-n] [-g|-b|-l|-x|-c ZIP] DIR [DIR [...]]
Compress all uncompressed files in DIR/archive
-c ZIP Use this compressor ZIP (std: $p).
-n dummy mode. Shows files which will be compressed, if not in dummy mode.
Predefined compressors: -g: gzip, -b: bzip2, -l: lzma, -x: xz
2011-02-23 15:39:35 +01:00
EOF
exit
}
while getopts he:ngblxc: o
2011-02-23 15:39:35 +01:00
do
case "$o" in
-) break ;;
h) help ;;
n) n=echo ;;
g) p=gzip ;;
b) p=bzip2 ;;
l) p=lzma ;;
x) p=xz ;;
c) p="$OPTARG" ;;
2011-02-23 15:39:35 +01:00
esac
done
shift `expr $OPTIND - 1`
2011-02-23 15:39:35 +01:00
[ 0 -lt $# ] || help
for d
do
find "$d" -name archive -type d -exec sh -c 'empty=
find "$1" -type f ! -name "*.bz2" ! -name "*.gz" ! -name "*.lzma" ! -name "*.xz" -exec '"$n"' '"$p"' -- "{$empty}" \;' -- '{}' \;
2011-02-23 15:39:35 +01:00
done