-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdateNotes.sh
More file actions
executable file
·56 lines (53 loc) · 1.68 KB
/
updateNotes.sh
File metadata and controls
executable file
·56 lines (53 loc) · 1.68 KB
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
46
47
48
49
50
51
52
53
54
55
56
# /home/peter/Desktop/uDrive/sp20/notes
NOTE_DIR=/home/peter/Documents/notes
U_DIR=/home/peter/Desktop/uDrive/Desktop/Stuff/math1080
if [ ! -d $U_DIR ]; then
# First check if target dir is mounted
echo "Mounting u-drive"
/home/peter/.scripts/mountUdrive.sh
fi
confirm(){
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
if [[ $response != n && $* == *-y* ]]; then
true
else
false
fi
;;
esac
}
for file in $NOTE_DIR/math1080_NoteKeys/*; do
# If remote file exists
if [ -f "$U_DIR/$(basename -- $file)" ]; then
# if (differ between src and dest) && (src older than dest)
# warn user
# diff $file $U_DIR/$(basename -- $file)
if [[ "$file" -ot $U_DIR/$(basename -- $file) ]] &&
! cmp -s $file $U_DIR/$(basename -- $file); then
echo " src older than dest: $(basename -- $file)";
ls -l $file $U_DIR/$(basename -- $file);
echo ""
# else
# echo "--> Updating $(basename -- $file) on u-drive"
fi
# else tell user that new file is being created
else
echo "--> Creating $(basename -- $file) on u-drive"
fi
done
confirm "Copy note directory? (def Y)" -y &&
echo "--> Copying note dir" &&
sudo cp $NOTE_DIR/math1080_NoteKeys/* $U_DIR/;
echo "--> Copying calendar"
sudo cp /home/peter/Dropbox/Grad_School/Clemson/teaching/math1080/fa21/misc/math1080_002_fa21Calendar.pdf $U_DIR/
# Display any differences between files
for file in $NOTE_DIR/math1080_NoteKeys/*;
do diff $file $U_DIR/$(basename -- $file);
done
echo "Done!"