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
This entry was posted in coding. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>