-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiff_env.sh
More file actions
executable file
·54 lines (47 loc) · 1.44 KB
/
diff_env.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.44 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
#!/bin/bash
set -e
OUTPUT_FILE="stdout.diff.log"
FILES_WITH_DIFF=0
FILES_IDENTICAL=0
FILES_MISSING=0
# Clear the output file
> "$OUTPUT_FILE"
echo "======================================"
echo "Environment Files Diff Check"
echo "======================================"
echo ""
while read f;
do
if [[ ! $f =~ ^#.*$ && ! -z $f ]];
then
echo -n "Checking $f ... "
if [[ ! -f ~/$f ]]; then
echo "MISSING (file doesn't exist in ~/$f)"
echo "=== MISSING: $f ===" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
FILES_MISSING=$((FILES_MISSING + 1))
elif diff -q "$f" ~/"$f" > /dev/null 2>&1; then
echo "identical"
FILES_IDENTICAL=$((FILES_IDENTICAL + 1))
else
echo "DIFFERENCES FOUND"
echo "=== DIFF: $f vs ~/$f ===" >> "$OUTPUT_FILE"
diff "$f" ~/"$f" >> "$OUTPUT_FILE" 2>&1 || true
echo "" >> "$OUTPUT_FILE"
FILES_WITH_DIFF=$((FILES_WITH_DIFF + 1))
fi
fi
done < files.txt
echo ""
echo "======================================"
echo "Summary:"
echo " Files with differences: $FILES_WITH_DIFF"
echo " Identical files: $FILES_IDENTICAL"
echo " Missing files: $FILES_MISSING"
echo ""
if [[ $FILES_WITH_DIFF -gt 0 || $FILES_MISSING -gt 0 ]]; then
echo " Detailed diff output saved to: $OUTPUT_FILE"
else
echo " All files are identical!"
fi
echo "======================================"