41 lines
721 B
Bash
Executable file
41 lines
721 B
Bash
Executable file
#!/bin/sh
|
|
|
|
help() {
|
|
cat <<EOF
|
|
Usage: `basename "$0"` -h | [-n] [-g|-b|-l|-x|-c PACKER] DIR [DIR [...]]
|
|
Komprimiert alle Dateien in DIR/archive.
|
|
-n Trockenlauf
|
|
Packer: -g: gzip, -b: bzip2, -l: lzma, -x: xz, -c PACKER: einen anderen.
|
|
EOF
|
|
exit
|
|
}
|
|
|
|
[ 0 -lt $# ] || help
|
|
x=`getopt he:ngblxc: "$@"` || exit 1
|
|
eval set -- $x
|
|
p=gzip
|
|
|
|
while [ 0 -lt $# ]
|
|
do
|
|
o=$1
|
|
shift
|
|
case "$o" in
|
|
--) break ;;
|
|
-h) help ;;
|
|
-n) n=echo ;;
|
|
-g) p=gzip ;;
|
|
-b) p=bzip2 ;;
|
|
-l) p=lzma ;;
|
|
-x) p=xz ;;
|
|
-c) p="$1" ; shift ;;
|
|
esac
|
|
done
|
|
|
|
[ 0 -lt $# ] || help
|
|
|
|
for d
|
|
do
|
|
find "$d" -name archive -type d -exec sh -c '
|
|
find "$1" -type f ! -name "*.bz2" ! -name "*.gz" ! -name "*.lzma" ! -name "*.xz" -exec '"$n"' '"$p"' -- "{}" \;' -- '{}' \;
|
|
done
|