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.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Dennis Williamson had a good answer, but I needed to do this recursively. GNU findutils 4.7.0 doesn't sort its output, so here's what I used
diff <(cd $dir1; find | sort) <(cd $dir2; find | sort)
To do this only one way, and produce a list of files, I used this:
diff <(cd $dir1; find | sort) <(cd $dir2; find | sort) \ | grep '< ./' | sed "s,< ./,$dir1/,"
For this to work properly, neither $dir1 nor $dir2 should include the trailing slash.