aboutsummaryrefslogtreecommitdiff
path: root/blogsend
blob: c25da95eba8c82997534a3ea5e08e37b7c084115 (plain) (blame)
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
37
38
39
40
41
#!/bin/sh

# 2025-05-15 17:06:00
# blogsend : scp blog files to web server
# usage    : blogsend hours (if not set default is 1 hour)
# example  : blogsend 72 sends files modified over the past 3 days

# folders
# Add your remote ssh folder, ex. server:/var/www/html/whatever
rf=
# Add your local folder, ex. ~/web
mf=

cd $mf || exit

# test $1
if [ -z "$1" ]; then
   hours=1;
else
  # test if var is a number
  if [ "$1" -eq "$1" ] >/dev/null 2>&1; then
    hours="$1";
  else
    hours=1;
  fi  
fi

minutes=$((hours*60))

printf "\033[0;33mSending files modified in the past $hours hour(s) to $rf\033[0m\n"

files=$(find -- * -iname "*.html" -path .tmp -prune -o -mmin -$minutes -type f) 
for file in $files 
do 
   printf %s "-> "; scp "$file" "$rf/$file";
done

printf "\033[0;33mDone.\033[0m\n"

exit 0