Find files in one directory not in another

Are there any Linux/Unix tools which find all the files in one directory not present in another? Basically I'm looking for diff which works on the output of ls.

Short and sweet scripts are also appreciated.


Solution 1:

diff does this already:

diff dir1 dir2

Example output:

Only in dir1: some_file.txt
Only in dir1: some_other_file.txt
Only in dir2: third_file.txt

Solution 2:

Bash:

diff <(cd dir1; ls) <(cd dir2; ls)

Compare only the filenames - not the contents of the files.

Solution 3:

Like people told you here, you can use DIFF in various usage variations. Or you just use dirdiff instead, which is meant for what you're trying! :-)

But if you want to keep some directories in sync then you really should take a look on rsync.

Regards