Monday, October 12, 2009

Diff two directories

If we wanted to find the differences between 2 directories we can use this commands:

ls -R$ ls -R 'directory1' > ls_dir1
$ ls -R 'directory2' > ls_dir2

Then we will change each file directory names for the same name. This way we could get better diff file.
sed$ sed -e 's/directory1/diff_name/' ls_dir1 > ls_dir1_sed
$ sed -e 's/directory2/diff_name/' ls_dir2 > ls_dir2_sed

And finally we'll do the diff, to see the differences:
diff
$ diff ls_dir1_sed ls_dir2_sed | more


Sed: http://www.gentoo.org/doc/es/articles/l-sed2.xml

No comments: