Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85534b130a | |||
| f391593857 |
+1
-1
@@ -1 +1 @@
|
|||||||
0.9.6
|
0.9.8
|
||||||
|
|||||||
+12
-11
@@ -3,14 +3,14 @@
|
|||||||
Src=${1}
|
Src=${1}
|
||||||
Days=${2}
|
Days=${2}
|
||||||
|
|
||||||
if [ "${Src}" == "" ]
|
if [ -z "$Days" ] || [ -z "$Src" ]; then
|
||||||
then
|
echo "Usage: $0 <source_dir> <num_days>"
|
||||||
echo "Usage: $0 <source_dir> [<num_days>]"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ "${Days}" == "" ]
|
|
||||||
then
|
# Add / if Src does not have it (symlinks)
|
||||||
Days=30
|
if [ "${Src: -1}" != "/" ]; then
|
||||||
|
Src="${Src}/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -A Settings=()
|
declare -A Settings=()
|
||||||
@@ -21,13 +21,13 @@ src=${Settings[Src]}
|
|||||||
prune_date=${Settings[PruneDate]}
|
prune_date=${Settings[PruneDate]}
|
||||||
|
|
||||||
|
|
||||||
echo "Finding files older than ${prune_date}..."
|
echo "Finding files older than ${prune_date} in ${Src} ..."
|
||||||
Cmd="find ${src} -type f ! -newermt \"${prune_date}\""
|
Cmd="find ${src} -type f ! -newermt \"${prune_date}\""
|
||||||
echo ${Cmd}
|
echo ${Cmd}
|
||||||
files=($(eval ${Cmd}))
|
files=($(eval ${Cmd}))
|
||||||
total_files= ${#files[*]}
|
total_files=${#files[*]}
|
||||||
|
|
||||||
if [[ ${total} == 0 ]]
|
if [[ ${total_files} == 0 ]]
|
||||||
then
|
then
|
||||||
echo "No files found to be pruned. Bye..."
|
echo "No files found to be pruned. Bye..."
|
||||||
exit 0
|
exit 0
|
||||||
@@ -38,11 +38,12 @@ duf ${src}
|
|||||||
|
|
||||||
echo "The following files will be removed:"
|
echo "The following files will be removed:"
|
||||||
echo "===================================="
|
echo "===================================="
|
||||||
for f in $files ; do echo $f; done
|
for f in $files ; do ls -l $f; done
|
||||||
echo "===================================="
|
echo "===================================="
|
||||||
echo "Total files to be pruned: ${total_files}"
|
echo "Total files to be pruned: ${total_files}"
|
||||||
|
|
||||||
Cmd="${Cmd} -delete"
|
echo "Removing files..."
|
||||||
|
Cmd="${Cmd} -print -delete"
|
||||||
echo ${Cmd}
|
echo ${Cmd}
|
||||||
eval ${Cmd}
|
eval ${Cmd}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user