Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two folders which have many files inside contents

Tags:

shell

unix

diff

Have two folders with approx. 150 java property files.

In a shell script, how to compare both folders to see if there is any new property file in either of them and what are the differences between the property files.

The output should be in a report format.

like image 439
vetri02 Avatar asked Oct 29 '09 15:10

vetri02


People also ask

How do you compare two folders and find missing files?

To see if two folders have the same file, you have to compare them and see if there are any differences. To do this, you can use a file comparison tool such as WinMerge, open it, go to the File tab, choose the folders you want to compare, and hit Compare.

Can Notepad ++ compare folders?

By default Notepad++ doesn't have compare function. We can make it possible by easily installing a compare plugin after Notepad++ is installed.


2 Answers

To get summary of new/missing files, and which files differ:

diff -arq folder1 folder2 

a treats all files as text, r recursively searched subdirectories, q reports 'briefly', only when files differ

like image 60
reko_t Avatar answered Nov 10 '22 00:11

reko_t


diff -r will do this, telling you both if any files have been added or deleted, and what's changed in the files that have been modified.

like image 23
John Kugelman Avatar answered Nov 10 '22 01:11

John Kugelman