Using Bash, I need to copy and override some files that have equal names but different contents from source, while ignoring equal files.
I saw no option in cp
's manual for copying only differing files.
First I tried using cp
's "update" option but it won't copy older files from source to destination.
cp -a -u SOURCE DESTINATION
If I remove the -u
parameter it does copy all files correctly, but I want to avoid unnecessary copies.
I need something like this:
- Source files must be copied when the destination is different from source.
- Sometimes the destination is newer than source. Still, the copy must be done.
- Only when source files are equal to the destination, they must be ignored.
How should I do that?
bash
in your example - while your script may be interpreted bybash
, you are usingcp
to copy files. – Panki Jan 07 '22 at 19:21