Created
November 28, 2012 01:22
-
-
Save alecthegeek/4158419 to your computer and use it in GitHub Desktop.
Compare two directories when you have an old tool chain (no diff -q)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
# Compare 2 directories for differences (e.g. current release and new release) | |
CURRENT=$1 ; shift | |
NEW=$1; shift | |
CURRENTDIFFFILE=/tmp/$(echo $CURRENT | sed -e 's/[/.][/.]*/_/g') | |
NEWDIFFFILE=/tmp/$(echo $NEW | sed -e 's/[/.][/.]*/_/g') | |
# File pattens not to be included in compare | |
cat << 'EOF' > /tmp/patternFile | |
^.git/ | |
^.*\.log | |
^logs/.* | |
^.*\.tmp | |
^.*\.err | |
EOF | |
for i in $CURRENT $NEW ; do | |
cd $i | |
# cut removed ./ that find puts at start of path name | |
find . -type f -print |cut -b3- |egrep -v -f /tmp/patternFile | sort > /tmp/$(echo $i | sed -e 's/[/.][/.]*/_/g') | |
cd - | |
done | |
echo New files | |
comm -13 $CURRENTDIFFFILE $NEWDIFFFILE | |
echo | |
echo Deleted files | |
comm -23 $CURRENTDIFFFILE $NEWDIFFFILE | |
echo | |
echo files that are different | |
# xargs has limitations so must pipe into a second shell | |
comm -12 $CURRENTDIFFFILE $NEWDIFFFILE | xargs -i echo cmp -s \"$CURRENT/{}\" \"$NEW/{}\" \|\| echo {} changed | sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment