blob: 4e8ab7910e084e1a1ec5dcc34ebdbc7cf684f499 (
plain)
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
|
#!/bin/bash
if [ $# -eq 2 ]
then
verbose=false
file1=$1
file2=$2
elif [ $# -eq 3 -a $1 = "-v" ]
then
verbose=true
file1=$2
file2=$3
else
echo "Usage: $0 [-v] file1 file2"
exit 1
fi
tmppfx=preload$$
formattedfile1=/tmp/$tmppfx-formatted1
formattedfile2=/tmp/$tmppfx-formatted2
idlist1=/tmp/$tmppfx-preload-ids-1
idlist2=/tmp/$tmppfx-preload-ids-2
echo "Comparing $file1 to $file2 ...."
cat $file1 | python3 -mjson.tool > $formattedfile1
cat $file2 | python3 -mjson.tool > $formattedfile2
cat $formattedfile1 | grep '"preload-id":' | cut -d: -f2 | sed -e "s/,$//" -e 's/\"//g' -e '/^[[:space:]]*$/d' | sort -u > $idlist1
cat $formattedfile2 | grep '"preload-id":' | cut -d: -f2 | sed -e "s/,$//" -e 's/\"//g' -e '/^[[:space:]]*$/d' | sort -u > $idlist2
echo
echo "Diff of preload ids:"
echo "--------------------"
diff $idlist1 $idlist2
if [ "$verbose" = "true" ]
then
echo
echo "Full diff:"
echo "----------"
diff $formattedfile1 $formattedfile2
fi
echo
echo "Preload id counts:"
echo "------------------"
echo " $file1 : $(cat $idlist1 | wc -l)"
echo " $file2 : $(cat $idlist2 | wc -l)"
|