Search code examples
linuxbashunixcygwincsh

diff two versions of a file that reside in different directories


I would like to diff two versions of a file that reside in different directories, for example:

diff ./dirA/foo.txt ./dirB/foo.txt

I vaguely remember there is a way to write this in a more condensed way, so that the filename appears only once. Something like:

diff {./dirA/, ./dirB/}foo.txt

Anyone know how to do this?


Solution

  • Close. No space.

    diff dir{A,B}/foo.txt
    

    or, in the more likely case that the two folders don't actually have a common substring like that,

    diff {dir,folder}/foo.txt
    

    And, should you want to compare the whole tree, note that diff has a recursive (-r) option.