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

前端 未结 9 1449
囚心锁ツ
囚心锁ツ 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:43

    In case you find it convenient, you could use the following Makefile. Just run: "make patch"

    #Makefile for patches
    
    #Exlude following file endings
    SUFFIX += o
    SUFFIX += so
    SUFFIX += exe
    SUFFIX += pdf
    SUFFIX += swp
    
    #Exlude following folders
    FOLDER += bin
    FOLDER += lib
    FOLDER += Image
    FOLDER += models
    
    OPTIONS = Naur
    
    patch: 
        rm test.patch
        diff -$(OPTIONS) \
        $(foreach element, $(SUFFIX) , -x '*.$(element)') \
        $(foreach element, $(FOLDER) , -x '$(element)*') \
            org/ new/ > test.patch  
    
    unpatch: 
        rm test.unpatch
        diff -$(OPTIONS) \
        $(foreach element, $(SUFFIX) , -x '*.$(element)') \
        $(foreach element, $(FOLDER) , -x '$(element)*') \
        new/ org/ > test.unpatch
    

提交回复
热议问题