diff to output only the file names

前端 未结 6 660
我在风中等你
我在风中等你 2021-01-29 18:28

I\'m looking to run a Linux command that will recursively compare two directories and output only the file names of what is different. This includes anything th

6条回答
  •  遇见更好的自我
    2021-01-29 18:55

    From the diff man page:

    -q   Report only whether the files differ, not the details of the differences.
    -r   When comparing directories, recursively compare any subdirectories found.

    Example command:

    diff -qr dir1 dir2
    

    Example output (depends on locale):

    $ ls dir1 dir2
    dir1:
    same-file  different  only-1
    
    dir2:
    same-file  different  only-2
    $ diff -qr dir1 dir2
    Files dir1/different and dir2/different differ
    Only in dir1: only-1
    Only in dir2: only-2
    

提交回复
热议问题