aboutsummaryrefslogtreecommitdiff
path: root/send-refresh.sh
blob: 388571c78b37a2e1d42d8dd804a12bb207689675 (plain)
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
30
31
32
33
34
35
36
#!/bin/bash

# Recursively delete directories by age (14 days), and only exactly at the depth of the base directory
#find /path/to/base/dir/ -mindepth 1 -maxdepth 1 -type d -ctime +14 -exec rm -rf {} \;


# Recursively discover files in the user's home directory, older than 14 days, and delete them
#find /path/to/home/dir/ -mindepth 1 -maxdepth 1 -type f -ctime +14 -exec rm -rf {} \;
# Recursively discover files in the user's home directory, younger than 14 days
#find /path/to/home/dir/ -mindepth 1 -maxdepth 1 -type f -ctime -14

# command for getting the filename out of a full path
#basename /path/to/file.zip

# Creating an array of homedirectory files younger than 14 days:

webdir="/path/to/public/webdir/"

young_files=()

while IFS=  read -r -d $'\0'; do
    young_files+=("$REPLY")
done < <(find /home/san/ -mindepth 1 -maxdepth 1 -type f -ctime -14 -name "*.zip" -print0)

# Looping over said array:

for file in "${young_files[@]}"; do
    filename=$(basename "$file")
    checksum=$(md5sum "$file" | awk '{print $1;}')
    
    echo "file: $file"
	echo "filename: $filename"
    echo "checksum: $checksum"
    
done