The --from-file
option allows you to compare one file against many files (rather than something like tar --files-from
which reads a list of files to operate on from a file). It has an analogous --to-file
, which of the two you use would depend on relative "direction" of the change. Since you're using -q
which only says if there is a difference, this hopefully should not matter to you here.
I assume you have a reference file, and you wish to compare it to a set of identically named files, so either of these should work:
diff -q --from-file dir1/protein.mol2 $(find . -name protein.mol2)
find . -name protein.mol2 | xargs diff -q --from-file dir1/protein.mol2
In the first case diff
will run only once, and its exit code will reflect whether or not any differences were found in the set.
In the second case diff
may run more than once. This second form can be used in case you have a large number of files (or very long file/directory names) and hit a command argument limit (usually 128kB on Linux systems).
diff $(find)
is really the same as e.g.mkdir $(date)
, orvar=$(pwd)
. Do you think those should be three separate questions? – Dmitry Grigoryev Oct 16 '15 at 13:21diff $(...)
style – Chris Davies Oct 16 '15 at 14:52