shell-scripte-code/compress.sh

38 lines
718 B
Bash
Raw Permalink Normal View History

2019-01-07 20:23:02 +01:00
#!/usr/bin/env bash
2017-10-03 21:40:13 +02:00
set -ex
archiv=$2
if [ "make" == "$1" ]; then
2018-11-11 04:24:37 +01:00
while (( "$(expr $# - 2)" ))
2017-10-03 21:40:13 +02:00
do
2018-11-11 04:24:37 +01:00
dateien="$3 ${dateien}"
2017-10-03 21:40:13 +02:00
2018-11-11 04:24:37 +01:00
shift
2017-10-03 21:40:13 +02:00
2018-11-11 04:24:37 +01:00
done
2017-10-03 21:40:13 +02:00
2018-11-11 04:24:37 +01:00
tar -cf ${archiv}.tar ${dateien}
pixz ${archiv}.tar ${archiv}.tar.pxz
2017-10-03 21:57:48 +02:00
2018-11-11 04:24:37 +01:00
# säuberung
rm ${archiv}.tar
2017-10-03 21:40:13 +02:00
elif [ "restore" == "$1" ]; then
2017-10-03 21:57:48 +02:00
2018-11-11 04:24:37 +01:00
pixz -d ${archiv} ${archiv/.pxz*}
2017-10-03 21:40:13 +02:00
2018-11-11 04:24:37 +01:00
tar -xf ${archiv/.pxz*}
2017-10-03 21:57:48 +02:00
2018-11-11 04:24:37 +01:00
# säuberung
rm ${archiv/.pxz*}
2017-10-03 21:40:13 +02:00
else
2018-11-11 04:24:37 +01:00
echo "tar.pxz compress-script"
echo "./compress.sh make/restore archivname input/output"
echo "./compress.sh make archivname daten"
echo "./compress.sh restore archivname"
echo "or use"
echo "tar -Ipixz -cf output.tpxz dir # Make tar use pixz automatically"
2017-10-03 21:40:13 +02:00
fi