Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compare two directories while ignoring certain directory names? [closed]

Tags:

linux

I want to iteratively compare two directories, A and B, under Linux using:

diff -r ./A ./B

but I want to ignore some subdirectory names, e.g. a subdirectory called "svn".

How do I do it under Linux?

like image 473
Hailiang Zhang Avatar asked Feb 27 '12 22:02

Hailiang Zhang


People also ask

How do you compare two directories and list differences?

Click on the “Select Files or Folders” tab in the far left, to start a new comparison. Each comparison you run opens in a new tab. To start a new comparison, click on the “Select Files or Folders” tab in the far left, change the targets and click “Compare” again.

Can you use diff on directories?

You can use diff to compare some or all of the files in two directory trees. When both file name arguments to diff are directories, it compares each file that is contained in both directories, examining file names in alphabetical order as specified by the LC_COLLATE locale category.

How do I compare the contents of two folders in Linux?

Click on directory comparison and move to the next interface. Select the directories you want to compare, note that you can add a third directory by checking the option “3-way Comparison”. Once you selected the directories, click on “Compare”.

How do you compare two folders in Python?

cmpfiles() method in Python is used to compare files in two directories. Multiple files can be compared using this method. This method returns three lists of file names namely match, mismatch and errors.


1 Answers

You can write:

diff -r --exclude=svn ./A ./B
like image 132
ruakh Avatar answered Nov 01 '22 23:11

ruakh