Skip to main content
deleted 120 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237

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?

Sorry that i can not construct any script with the question, i'm very new to scripting and linux and still learning =(

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?

Sorry that i can not construct any script with the question, i'm very new to scripting and linux and still learning =(

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?

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

Compare existing file in 2 dirtwo different directories, copy isif not exist or overwitreexistent, else overwrite it

Source Link
Loading