summaryrefslogtreecommitdiff
path: root/check-diff
blob: 8643e04234ecbfc7e0eaa77b7f87e596ffef610d (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
#!/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'"