You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
358 B
Bash
23 lines
358 B
Bash
3 years ago
|
#!/bin/bash
|
||
|
|
||
|
|
||
|
if [ -z "$1" ]
|
||
|
then
|
||
|
echo "Cleaning in working directory!"
|
||
|
else
|
||
|
echo "Cleaning in $1!"
|
||
|
cd $1
|
||
|
fi
|
||
|
|
||
|
for d in */ ; do
|
||
|
DIR_DATE=$(echo $d| head -c 10)
|
||
|
expration_DATE=$(date -d "-10 days" --iso-8601)
|
||
|
echo $expration_DATE vs $DIR_DATE
|
||
|
if [[ "$expration_DATE" > "$DIR_DATE" ]]
|
||
|
then
|
||
|
echo "Purging old directory $d..."
|
||
|
rm -rf $d
|
||
|
fi
|
||
|
done
|
||
|
|