-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup
More file actions
executable file
·34 lines (32 loc) · 816 Bytes
/
backup
File metadata and controls
executable file
·34 lines (32 loc) · 816 Bytes
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
#! /bin/csh
#echo Start
set Total = 0
set BD = BackDir
#ls *~
if( ! -e $BD ) then
mkdir $BD
endif
foreach i (`ls *~ *\#*`)
# echo ============== Backing up $i
#Count the number of backups for this file
set Total = `ls $BD/$i* | wc -l`
# echo There are $Total
#Compare this backup to the last one in the directory.
#If different, copy this backup to the Backup Directory,
#increasing the number suffix.
#If there's no change, remove it.
if( $Total == 0 ) then
@ Total = $Total + 1
echo Moving $i
mv $i $BD/$i"."$Total
else
if( `diff $i $BD/$i"."$Total |wc -l` != 0 ) then
@ Total = $Total + 1
echo Moving $i
mv $i $BD/$i"."$Total
else
echo removing $i Backup exists.
rm $i
endif
endif
end