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.
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.
diff
does this already:Example output:
Bash:
Compare only the filenames - not the contents of the files.
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
If you are wanting to do this through all sub directories as well, a good way to do it is:
I prefer using brief, but you can leave that out if you want.
for i in $(ls -1 directory1); do if (test -f directory2/$i) then echo $i; fi; done
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
To do this only one way, and produce a list of files, I used this:
For this to work properly, neither $dir1 nor $dir2 should include the trailing slash.
This works..
untested: