added version number and info how to remove sources

This commit is contained in:
Ville Rantanen
2016-02-17 10:20:22 +02:00
parent 82833bff40
commit 7b4d17d4c3

View File

@@ -1,9 +1,10 @@
#!/bin/bash
VERSION="20160217"
function helpexit() {
BS=$( basename "$0" )
echo Archive the subfolders of the current directory
echo "Archive the subfolders of the current directory, version: $VERSION"
echo "Usage: $BS [-z/-n] [folder name(s)]"
echo " -z Compress. If not given, will ask action after archiving"
echo " -n No compression. Exit after TARchive"
@@ -23,6 +24,12 @@ function fsize() {
function killtrap() {
kill "$PID" &>/dev/null
}
function exitokay() {
echo -ne "\nIf all looks okay, delete source folders with: # rm -r '"
listfolders "${FOLDERS[@]}" | sed -e "s/\x0/' '/g" -e "s,..$,,"
echo ''
exit
}
DEPTH=1
FOLDERS=( )
@@ -31,6 +38,7 @@ for ((i=1; i<=${#@}; i++)) {
[[ "${!i}" = "--help" ]] && helpexit
[[ "${!i}" = "-n" ]] && { NOCOMPRESSION=1; continue; }
[[ "${!i}" = "-z" ]] && { COMPRESSION=1; continue; }
[[ "${!i}" = "-"* ]] && helpexit
FOLDERS+=( "${!i%/}" )
DEPTH=0
}
@@ -72,7 +80,7 @@ listfolders "${FOLDERS[@]}" | while read -r -d "" d; do
done
trap - 9 15
[[ "$NOCOMPRESSION" -eq 1 ]] && {
exit
exitokay
}
[[ "$COMPRESSION" -eq 1 ]] || {
echo 'Proceed to compress? <ctrl-c> to quit'
@@ -98,4 +106,4 @@ listfolders "${FOLDERS[@]}" | while read -r -d "" d; do
fsize "$d.tar.gz" "$DU"
echo ''
done
exitokay