How do you diff a directory for only files of a specific type?

前端 未结 9 1480
囚心锁ツ
囚心锁ツ 2021-01-31 13:15

I have a question about the diff command if I want a recursive directory diff but only for a specific file type, how to do that?

I tried using the exclude option but can

9条回答
  •  遇见更好的自我
    2021-01-31 13:36

    Whilst it does not avoid the actual diff of other files, if your goal is to produce a patch file, or similar then you can use filterdiff from the patchutils package, e.g. to patch only your .py changes:

    diff -ruNp /path/1 /path/2 | filterdiff -i "*.py" | tee /path/to/file.patch
    

提交回复
热议问题