summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-12-17 09:09:07 +0100
committerErich Eckner <git@eckner.net>2017-01-05 21:57:13 +0100
commitd19da7c994311424166bcefcadfe2d66c023bf95 (patch)
treea2c13419cf7ab4e6dcc46a829279837284ae3154
parentc62830765874afc763db38ac01e8be9f3ca092e7 (diff)
downloadhardlinkedBackups-d19da7c994311424166bcefcadfe2d66c023bf95.tar.xz
simple script for checking diff of files
-rwxr-xr-xcheckDiff28
1 files changed, 28 insertions, 0 deletions
diff --git a/checkDiff b/checkDiff
new file mode 100755
index 0000000..8643e04
--- /dev/null
+++ b/checkDiff
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+a="$1"
+aDat="$(
+ echo "${a}" | \
+ tr '/' '\n' | \
+ grep -m1 '^[0-9]\{4\}\(_[0-9]\{2\}\)\{2\}$'
+)"
+dir="$(
+ echo "${a}" | \
+ sed "s|/${aDat}/.*$||"
+)"
+bDat="$(
+ ls -1 "${dir}" | \
+ grep -v "^${aDat}\$" | \
+ grep '^[0-9]\{4\}\(_[0-9]\{2\}\)\{2\}$' | \
+ sort | \
+ tail -n1
+)"
+b="$(
+ echo "${a}" | \
+ sed "s|/2016_12_[0-9][0-9]/|/${bDat}/|"
+)"
+
+(diff -q "$a" "$b" 2> /dev/null > /dev/null) \
+ && [ "$(stat "$a" -c'%h')" -lt 64000 ] \
+ && [ "$(stat "$b" -c'%h')" -lt 64000 ] \
+ && echo "'$a' equals '$b'"