Diff files present in two different directories

前端 未结 8 2153
你的背包
你的背包 2020-11-30 16:23

I have two directories with the same list of files. I need to compare all the files present in both the directories using the diff command. Is there a simple co

8条回答
  •  孤街浪徒
    2020-11-30 16:50

    If you specifically don't want to compare contents of files and only check which one are not present in both of the directories, you can compare lists of files, generated by another command.

    diff <(find DIR1 -printf '%P\n' | sort) <(find DIR2 -printf '%P\n' | sort) | grep '^[<>]'
    

    -printf '%P\n' tells find to not prefix output paths with the root directory.

    I've also added sort to make sure the order of files will be the same in both calls of find.

    The grep at the end removes information about identical input lines.

提交回复
热议问题