Sponsored Links

Maxabout.com > Tips

Comparing Two Files Or Two Directories

Added on:8/22/2008 12:32:20 AM
In Linux Tips
 Rated by 1 users


  1. To show all the lines that differ between file1 and file2:
    diff file1 file2

  2. To create a patch listing the changes from version1 to version2:
    diff -aur version1 version2 >dir2.diff

  3. To apply the patch to version1 and produce version2:
    patch -p1 <dir2.diff

  4. For text files where the wrapping of paragraph may have changed, use 'wdiff'.

  5. To compare two directories:
    diff -r --brief dir1 dir2

  6. To copy the content of dir1 into dir2 without the copying the files that already exist and are the same, use rsync:
    rsync -a dir1 dir2

  7. If you want to copy the newest files and delete the ones (make dir2 a miror copy of dir1:)
    rsync -a --delete dir1 dir2

  8. To synchronize two directories (in both directions), I use the program 'unison'


Sponsored Links
Tools
Bookmark/Discuss