"Andreas R." <[EMAIL PROTECTED]> wrote:
>> find dir1 -exec diff -q "{}" dir2/`basename {}` \;

Here, the command substitution is expanded by the shell before find
runs.  basename sees the literal argument {}, and so it outputs {},
and find sees dir2/{}.

>> find dir1 -exec sh -c "diff -q {} dir2/`basename {}`" \;

Here, agin, the command substitution is expanded before find runs.
Double quotes don't prevent an inner command substitution from being
expanded.  Single quotes will, though.  This will do what you want:

find dir1 -exec sh -c 'diff -q {} dir2/`basename {}`' \;

But if the filename contains any whitespace or shell metacharacters,
it'll cause trouble.  You can protect against that like this:

find dir1 -exec sh -c 'diff -q "$0" dir2/"`basename "$0"`"' {} \;


paul


Reply via email to