Compare Directory Contents on Linux computer
#/bin/bash
DIR_1=$1
DIR_2=$2
#check dir diffs
ls -1 $DIR_1 >/tmp/diff.1
ls -1 $DIR_2 >/tmp/diff.2
echo "Check Dir differences:"
diff /tmp/diff.1 /tmp/diff.2 && echo "Dir's have the same files"
#check files differences
echo "check files differences:"
for file in `cat /tmp/diff.1 /tmp/diff.2|uniq`; do
diff $DIR_1/$file $DIR_2/$file 2>/dev/null
done
rm /tmp/diff.1 /tmp/diff.2
4 Comments:
Missing $ sign; should be:
DIR_1=$1
DIR_2=$2
Hey vtmckoy,
Thanks for the heads up on that...
Thanks for the script. As vtmckoy posted, you should modify the two definitions, moving the $ sign to the other side of the equality. You might want to perform the modification in the post.
fer,
Hey thanks for the correction. I have implemented the changes.
Post a Comment
<< Home