From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 Description of problem: Would it be possible to extend the "diff" utility to operate like "mv" and "cp" in the above situation? The output should be similar to the output of "diff directory1 directory2". The files "file1" ... "filen" should be compared to the files of the same names in the directory "directory". Any other files in the directory "directory" should be ignored. If POSIX forbids this, could another utility be created that works like "diff" but has this feature? Version-Release number of selected component (if applicable): How reproducible: Didn't try Steps to Reproduce: 1. diff file1 file2 directory Actual Results: error message Expected Results: file1 should be compared to directory/`basename file1`. If they differ, the equivalent "diff" command should be printed followed by normal "diff" output. file2 should be compared to directory/`basename file2`. If they differ, the equivalent "diff" command should be printed followed by normal "diff" output. directory/file3 should be ignored, i.e., no "Only in directory: file3" message should be printed. Additional info: You can sort of do this by copying the requested files and their partners in the requested directory to temporary directories and then running "diff tmpdir1 tmpdir2" but then the "diff" lines will have tmpdir1 and tmpdir2 instead of the original locations of the files. Plus it seems wasteful to do more file copying than strictly necessary.
This isn't hard to do in a few lines of shell: #!/bin/bash TMPDIR=$(mktemp -d mydiff.XXXXXX) || exit 1 FILES=("$@") DIR=${FILES[$(($# - 1))]} unset FILES[$(($# - 1))] cp -l ${FILES[@]} "$TMPDIR" diff -ur "$TMPDIR" "$DIR" | \ filterdiff --strip=1 --addprefix=$(dirname "$DIR/.")/ rm -rf "$TMPDIR" It's not something we're likely to add to diffutils I'm afraid, since for one thing it makes the meaning of several of the options much less clear-cut. Feel free to discuss it with the upstream maintainer of diffutils of course.
diffutils 2.7.2 has the "--to-file" option which allows diff file1 file2 file3 --to-file=directory