additional dev of archival

This commit is contained in:
q
2016-02-15 22:55:47 +02:00
parent a95b20120c
commit c7c1c20c70

View File

@@ -4,8 +4,13 @@
function helpexit() {
echo Archive the subfolders of the current directory
echo " -z Compress. If not passed, will ask after tar archive"
echo " -n No compression. Exit after tar archive"
exit
}
function fsize() {
echo -en "\e[2K\r"
ls -sh "$1" | xargs echo -n
}
[[ "$1" = "-h" ]] && helpexit
@@ -21,14 +26,18 @@ find . -mindepth 1 -maxdepth 1 -type d -print0 | sort | while read -r -d "" d; d
echo -n $d
tar cvf "$d.tar" $d > "$d.tar.txt" &
PID=$!
while kill -0 "$PID" >/dev/null 2>&1; do
sleep 5
echo -en "\r"
ls -sh "$d.tar" | xargs echo -n
while kill -0 "$PID" &>/dev/null; do
for i in {1..5}; do
sleep $i; kill -0 "$PID" &>/dev/null || break 2
done
echo -en "\r"
ls -sh "$d.tar"
fsize "$d.tar"
done
fsize "$d.tar"
echo ''
done
[[ "$1" = "-n" ]] && {
exit
}
[[ "$1" = "-z" ]] || {
echo 'Proceed to compress? <ctrl-c> to quit'
read foo
@@ -39,11 +48,12 @@ find . -mindepth 1 -maxdepth 1 -type d -print0 | sort | while read -r -d "" d; d
gzip "$d.tar"
PID=$!
while kill -0 "$PID" >/dev/null 2>&1; do
sleep 5
echo -en "\r"
ls -sh "$d.tar" | xargs echo -n
for i in {1..5}; do
sleep $i; kill -0 "$PID" &>/dev/null || break 2
done
echo -en "\r"
ls -sh "$d.tar"
fsize "$d.tar.gz"
done
fsize "$d.tar.gz"
echo ''
done