adan
adan

Reputation: 21

Compare files in a directory with content in other files

I want to compare files of a directory with content in other file .i.e I have a folder(A) that contains multiple files. and I have a file(final.txt) in other folder that contains name of files present in "A" . All I want is, compare filename of files present in the directory A within the file "final.txt". if file name is already in final.txt then skip that file else copy the file to "B" directory from "A."

Upvotes: 0

Views: 54

Answers (1)

Shawn
Shawn

Reputation: 52334

rsync to the rescue:

rsync -rv --exclude-from=final.txt a/ b/

This copies all the files from directory a to directory b if they aren't listed in final.txt (Or if they already exist in b)

Upvotes: 3

Related Questions