Reputation: 989
I have two main directories (/home/Rash/A and /home/Rash/B) of the same CPP project. However, some .cpp and .h files inside B directory have been modified. My question is how can I know which .cpp and .h files of B directory are different with their identical ones in A? I mean with the same file names and sub directories. I am more looking for a command or script which compares the contents of the files with the same names and subdirectories in A and B and reports me the files with differences in terms of their contents.
Upvotes: 0
Views: 107
Reputation: 27567
You want something like this:
for i in /home/Rash/A/*.{cpp,h}; do
j=${i//A/B/}
if [ -e $j ]; then
echo comparing $i and $j
diff $i $j
fi
done
Upvotes: 1