Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7807501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:52:16+00:00 2026-06-02T02:52:16+00:00

How can you perform a recursive diff of the files in two directories (a

  • 0

How can you perform a recursive diff of the files in two directories (a and b):

$ diff -r a b

but only look at files whose name matches a given pattern. For example, using the same syntax available in the find command, this would look like:

$ diff -r a b -name "*crazy*"

which would show diffs between files with the same name and path in a and b, which have “crazy” in their name.

Effectively, I’m looking for the opposite of the –exclude option which is available in diff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:52:18+00:00Added an answer on June 2, 2026 at 2:52 am

    Perhaps this is a bit indirect, but it ought to work. You can use find to get a list of files that don’t match the pattern, and then “exclude” all those files:

    find a b -type f ! -name 'crazy' -printf '%f\n' | diff -r a b -X -
    

    The -X - will make diff read the patterns from stdin and exclude anything that matches. This should work provided your files don’t have funny chars like * or ? in their names. The only downside is that your diff won’t include the find command, so the listed diff command is not that useful.

    (I’ve only tested it with GNU find and diff).

    EDIT:

    Since only non-GNU find doesn’t have -printf, sed could be used as an alternative:

    find a b -type f ! -name '*crazy*' -print | sed -e 's|.*/||' | diff -X - -r a b
    

    That’s also assuming that non-GNU diff has -X which I don’t know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to call a nested recursive perl function, but I can't tack the
I am looking for XML/XHTML Java library/framework that can perform the following two tasks
What packages and functions in R can perform a two dimensional non-additive local regression/smooth.
Possible Duplicate: How can I perform full recursive directory & file scan? I can't
we can perform vim substitute on a set of lines by selecting them in
In Rails 3 I can perform query on associated models: EXAMPLE 1: model.associated_models.where(:attribute =>
can anyone suggest me a plugin/tool that can perform a code formatting at build
On an NVIDIA card I can perform full scene anti-aliasing using the accumulation buffer
Let's assume that our system can perform actions, and that an action requires some
Using the JavaScript Native Interface of GWT I can perform the following: public native

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.