-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21T2_q11.sh
More file actions
executable file
·47 lines (38 loc) · 951 Bytes
/
21T2_q11.sh
File metadata and controls
executable file
·47 lines (38 loc) · 951 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
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env dash
d1="$1"
d2="$2"
path1=$(mktemp)
path2=$(mktemp)
trap 'rm -f "$path1" "$path2"' EXIT
find "$d1" -type f | sed -E s"/^$d1\///" | sort | uniq > "$path1"
find "$d2" -type f | sed -E s"/^$d2\///" | sort | uniq > "$path2"
same_size=0
diff_size=0
only_1=0
only_2=0
while read -r path_from_1
do
if grep -xq "$path_from_1" "$path2"
then
file1="$d1/$path_from_1"
file2="$d2/$path_from_1"
size1=$(ls -l "$file1" | tr -s " " | cut -d" " -f5)
size2=$(ls -l "$file2" | tr -s " " | cut -d" " -f5)
if [ "$size1" -eq "$size2" ]
then
same_size=$((same_size + 1))
else
diff_size=$((diff_size + 1))
fi
else
only_1=$((only_1 + 1))
fi
done < "$path1"
while read -r path_from_2
do
if ! grep -xq "$path_from_2" "$path1"
then
only_2=$((only_2 + 1))
fi
done < "$path2"
echo "$same_size $diff_size $only_1 $only_2"