I'm trying to build a scrip that compare a file inside different 2 dir,then copy them from dir1 to dir2 is it's not exists in the dir2, or overwrite it if its already existed.
I know that i can use diff dir1 dir2 but then how do copy the result over to dir2. because diff command give me result like only in dir1: file1.txt, from my understand that isn't a file itself(right?)
For the overwrite part, i decide to use [ -ot ] command, but again, from my understand the [ -ot ] only can compare with file but not dir?