Compare folders and find missing files
Chris Green
cl at isbd.net
Wed Mar 25 09:02:10 UTC 2020
On Wed, Mar 25, 2020 at 12:40:09AM -0700, P. Echols wrote:
> Greetings all,
>
> is there a way to get "find" to return only when a file is NOT found?
>
> I am attempting to list the files on a flash drive (/media/project/) ,
> but ONLY, if those files don't exist in a particular folder in my
> computer (~/Documents/sub-tree/). If I cd to the sub-tree folder, I
> can run the following:
>
> find /media/project/ -type f -exec basename {} \; | while read fname;
> do find -name "$fname"; done
>
> This will list the path and file name for all the files that are
> found. But not the ones that are not found. Any thoughts how I might
> accomplish this?
>
Try 'diff', it can compare directories and tell you which files are
only in one or the other directory, you'll need to set a few options to
get the level of reporting you want.
--
Chris Green
More information about the ubuntu-users
mailing list