Skip to content

Commit 113e692

Browse files
committed
First submission
0 parents  commit 113e692

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cruft_remover.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
read -rp "Which folder you want to cruft? " FOLDER
4+
5+
if [ ! -d "$FOLDER" ]; then
6+
echo "Folder you type is not exists."
7+
exit 1
8+
fi
9+
10+
read -rp "How many days files should be unmodified for to be considered cruft? " DAY
11+
12+
readarray -t FILES < <(find "$FOLDER" -maxdepth 1 -atime -"$DAY" -type f)
13+
14+
if [ "${#FILES[@]}" -eq 0 ]; then
15+
echo "The folder of $FOLDER does not contains any file"
16+
exit 1
17+
fi
18+
19+
for FILE in "${FILES[@]}"; do
20+
rm -i "$FILE";
21+
done

0 commit comments

Comments
 (0)