-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrcheck.sh
executable file
·45 lines (33 loc) · 956 Bytes
/
rcheck.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#
# rsync script to check for changes,
#
# usage: ./rcheck.sh local remote
#
if [ ! $1 ]
then
#echo usage
echo -e "\n##### Usage #####\n"
echo "rcheck.sh /path/to/directory user@host:/path/to/directory"
echo -e "\nor\n"
echo "rcheck.sh /path/to/specific/file user@host:/path/to/file"
echo -e "\n\nYou can pass the remote or the local path first, order doesnt matter."
else #use rsync
source=$1 #source specification
dest=$2 #destination specification
#did user provide a trailing slash?
source=`echo "${source}" | sed -e "s/\/*$//"`
# dest=`echo "${dest}" | sed -e "s/\/*$//"`
#rsync call sent to "output" for processing
rsync --checksum --itemize-changes --dry-run $source/* $dest > output
if [ -s $output ]
then
echo "Files Changed:"
#print second field of rsync output, which is the file names
awk '{print $2 "\t changed"}' output
#cleanup
rm output
else
echo "No Changes."
fi
fi