Is there a way to compare output from find with diff in a bash shell? -
i'd take output of find , able compare them diff, see if files identical. instance, let's find few files find:
find . -name '*.bar' ./desktop/filename.bar ./otherdirectory/filename2.bar ./otherotherdirectory/filename3.bar
i'd able do
diff ./desktop/filename.bar ./otherdirectory/filename2.bar
and
diff ./desktop/filename.bar ./otherotherdirectory/filename3.bar
and on pairs of files found (to see @ least if files identical) without having write command line each pair.
the find -exec option won't work because replaces {} each result once @ at time:
find . -name '*.bar' -exec diff {} \;
i have tried piping outputs of find diff, can't work, either (though i'm still newbie , may doing wrong):
find . -name '*.bar' | diff
this may not doable, i'd rather not have write diff command every pair of files find find.
rather attempting diff
possible pairs of files in order determine duplicates, use sha256sum
, compare checksums instead:
find . -name '*.bar' -type f -exec sha256sum {} \;
identical files have same checksum. pipe output of above command sort
result sorted checksum:
find . -name '*.bar' -type f -exec sha256sum {} \; | sort
Comments
Post a Comment