Comparing directories
Hi everyone,
I have to compare two directories in order to indentify which files are changed, which files were added and which ones were deleted. I would like to see output something like this when comparing two directories dir1 and dir2: dir1/file1 - changed dir1/file2 - missing dir1/file3 - added Is there an utility in Linux that can easily do this? I expect diff should know how to do this, but I cannot figure out how to tell diff what I want. Could anyone help me? Thank you in advance. |
Try dircmp and diff commands [don't forget to check out their man pages].
Regards |
"man diff", look for recursion flag, look for "minimal output" flag: end up with "diff --brief -r dir1 dir2".
(FCOL: experiment will ya! ;-p ) |
Thanks for replies.
What I was doing up to the moment is: diff -qr dir1 dir2 Because I need only list of the files that changed/missed/added, I don't like output like: File dir1/file1 and dir2/file2 differ Only in dir2/: file2 Only in dir1/: file3 I want to see something simpler and I though that there could be some option which I couldn't figure out: ! dir1/file1 - dir1/file2 + dir1/file3 I think I just have to write simple script to reformat output the way I need it. |
You could use sed to convert the format. For example
sed '/differ/s/Files \(.*\) and .* differ/! \1/' to convert from Files dira/b and dirb/b differ to ! dira/b ---- diff -qr dirb dira | sed -e '/differ/s/Files \(.*\) and .* differ/! \1/' \ > -e '/Only/s/Only in \(.*\): \(.*\)/+ \1\/\2/' ! dirb/b ! dirb/e + dira/g + dirb/h |
Quote:
|
All times are GMT -5. The time now is 06:05 PM. |