-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnomatch4
More file actions
executable file
·70 lines (60 loc) · 1.16 KB
/
nomatch4
File metadata and controls
executable file
·70 lines (60 loc) · 1.16 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Usage: nomatch4 <dir>
# Checks if any of the local files agree with any of the ones in the target dir (recursive). Listst all local files not matched.
if [ -z "$1" ]
then
echo "Default dir: /tmp/, using this one"
remdir=/tmp
else
remdir=$1
fi
if [ ! -d "$remdir" ]
then
echo "Can't find $remdir"
exit
fi
# For all local files
for i in *
do
if [ ! -f "$i" ]
then
continue
fi
matched=0
mkdir -p matched/
# For all remote files
for j in $(find "$remdir" -type f)
do
### Nice try; didn't work. Test: cmp ~ 10sec; diff: ~13sec; size check: ~ 26 sec; checksum: ~ 112 sec :-)
### Size check
## ezmeret=$(stat -c%s "$i")
## azmeret=$(stat -c%s "$j")
## if [ "$ezmeret" -eq "$azmeret" ]
## then
##
### Checksum check
## ezchks=($(md5sum "$i"))
## azchks=($(md5sum "$j"))
## if [ "$ezchks" == "$azchks" ]
## then
####diff $i $j >/dev/null
cmp -s "$i" $j
if [ "$?" -eq "0" ]
then
matched=1
echo "$i $j match"
mv "$i" matched/
fi
## fi
## fi
done
if [ "$matched" -eq "0" ]
then
filelist=("${filelist[@]}" "$i")
fi
done
echo "======== 8< ========"
for i in "${filelist[@]}"
do
echo "No match for: $i"
done