I have two directories - one from earlier backup and second from newest backup. How do i compare what changes were made to files in directory from newest backup on Linux? Also how do i display changes in for example text and php files - i'm thinking about something like revision history on wikipedia where you see old version on one side of the screen and newest version on other and changes are highlighted. How do i achieve something like that?
edit: How do i also compare remote dir with local?
From diff man page:
So to compare directories:
diff --brief -r dir1 dir2
To compare files side by side:
diff --side-by-side file1 file2
Assuming:
www1
, comparing with remotewww2
www1
to remotewww2
www1
and remotewww2
You really want to combine the power of
rsync
to reduce bandwidth consumption with the power ofdiff
to give you flexible, well um diffs.So something like this:
I guess you could tweak this a bit if you were doing it often use
rsync
instead ofcp
in the first line - obviously in the last line you have the full power ofdiff
to format it however you like. Probably with y in the OPs caseDownside of this approach is you end up using twice as much local space, but at less than $1/gig who cares?
Do
diff old_dir new_dir > diff.txt
for side by side differences on the same server.For remote files:
For example : ABC is existing server and XYZ is your remote server and directory name is 123.
Step 1: Rename existing directory 123 on ABC Server as 123_ABC.
Step 2: Create a new directory on the server ABC:
Step 3: Copy all files from directory 123 on XYZ server to 123_XYZ directory on ABC server:
This will copy all files from the directory on your XYZ server to your ABC server/ 123_XYZ directory.
Step:4 : Do the diff between both directories:
Now go to ABC server and perform diff between 123_ABC and 123_XYZ
The command above will save the diff results in to diff.txt in the same path.
You may compare the differences then.
Thank you,
Mehul
AIDE Advanced Intrusion Detection Environment (AIDE) is a file integrity checker for UNIX operating systems. Its purpose to provide reporting on the integrity of data on supported file systems. By running AIDE multiple times on the target host you can determine what files are changing. By running AIDE multiple times on different hosts you can determine what files and permissions are different. Then use a gui diff tool on the reported "different" files.
Or use a gui diff tool like meld, guiffy, kdiff3, diff, vimdiff, gvimdiff, Emacs, Kompare, Diffuse, Easydiff, TkDiff or xxdiff. Most will do directory diffs in addition to file diffs. You'll need to mount the remote drive using NFS, SMBFS or SSHFS as others have mentioned.
Or you can use two files with the out put of list of files. And then compare those two files. For example:
Download one of the files.
to FILE.TXT
Use diff (
diff -y remote-files local-files > diff-files
) to compare them side by side. Open the diff-files and check it. Each line with > means a different file.