source: lab.git/TipAndDoc/.bin/cmpdir @ 5eea6d8

trunk
Last change on this file since 5eea6d8 was 5eea6d8, checked in by mitty <mitty@…>, 12 years ago
  • about #55
  • find -> sort -> uniq -> xargs -> cmp
  • don't check existence of path
  • don't check path is regular file or directory

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@170 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100755
File size: 810 bytes
RevLine 
[5eea6d8]1#! /bin/sh
2
3if [ $# -lt 2 ]; then
4    echo "Usage: $0 directory1 directory2"
5    exit 1
6fi
7if [ -d "$1" -a -d "$2" ]; then
8    echo "$0: start comparing '$1' and '$2'" >&2
9fi
10
11list=`mktemp --tmpdir cmpdir.list.XXXXXXXXXX` || exit 1
12tmp=`mktemp --tmpdir cmpdir.tmp.XXXXXXXXXX` || exit 1
13trap "rm -- '$list' '$tmp'" EXIT
14
15wc=$PWD
16cd "$1"
17find ./ -print0 >> "$tmp"
18cd $wc
19
20cd "$2"
21find ./ -print0 >> "$tmp"
22cd $wc
23
24sort -z "$tmp" | uniq -z > "$list"
25
26comppath () {
27    [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
28        (echo "$0: something wrong abount '$3'" >&2; return)
29    [ -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
30        (echo "Only in '$1': '$3'" >&2; return)
31    [ ! -e "$1/$3" ] && [ -e "$2/$3" ] &&
32        (echo "Only in '$2': '$3'" >&2; return)
33}
34
35xargs -a "$list" -0 -n 1 -I entry cmp "$1/entry" "$2/entry"
Note: See TracBrowser for help on using the repository browser.