diff has an option --recursive (-r) to do a comparison between two directories (the files inside them). Is there a way to make diff ignore certain sub-directories (eg: .svn)?

$ diff -r src1/ src2/

2 Answers 2


Add --exclude=".svn" as an option like so:

$ diff -r --exclude=".svn" src1/ src2/
  • 7
    If you want to exclude multiple items just add another --exclude parameter.
    – JonMR
    Jul 12, 2011 at 16:02
  • 19
    If you don't want to type --exclude every time use -x ".svn"
    – acorello
    Aug 14, 2012 at 9:03
  • 1
    --exclude option is also not working on mac os. -x ".svn" works well.
    – alpert
    Mar 29, 2016 at 11:13
  • --exclude works well on macOS 10.15.2, /usr/bin/diff 2.8.1 Mar 9, 2021 at 13:00
  diff --exclude=.svn ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.