Bash Script to Compare Two Folders and Copy Non Existant Files

  • Thread starter Thread starter jmadero
  • Start date Start date
J

jmadero

Hi All,

Trying to make a pretty basic bash script. The first thing that I need to do is compare two folders and copy any files that don't exists in folder2 but do exist in folder1 to folder2.

Example:
Folder1 Contains: 12.txt, abc.txt, 2bad.txt
Folder 2 Contains: 12.txt,2bad.txt

I need the script to compare the two folders and copy/paste abc.txt into Folder 2.

Notes:
1. I'll need some kind of a loop because I add files to Folder1 routinely and the point is to create a cron job which will continue to populate Folder2.

Thanks!

Continue reading...
 
Back
Top