-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclearcliphis.sh
executable file
·29 lines (23 loc) · 955 Bytes
/
clearcliphis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Set the directory path
directory="$XDG_CONFIG_HOME/clipmenu.6.system"
# Calculate the current timestamp
current_timestamp=$(date +%s)
# Iterate over each file in the directory
for file in "$directory"/*; do
# Check if the file exists and isn't lock*
if [ -f "$file" ] && [[ "$file" != "lock" ]] && [[ "$file" != "session_lock" ]]; then
# Get the file's last modification timestamp
timestamp=$(stat -c %Y "$file")
# Calculate the difference in seconds between the current timestamp and the file's timestamp
time_diff=$((current_timestamp - timestamp))
# Calculate the number of seconds in a month (30 days)
month_in_seconds=$((30 * 24 * 60 * 60))
# Check if the file exists longer than a month
if [ "$time_diff" -gt "$month_in_seconds" ]; then
# Delete the file
rm -v "$file"
echo "Deleted file: '$file'"
fi
fi
done