Anna K
Anna K

Reputation: 1774

How to copy 2 directories in linux overwritting only older files in bash

I wrote a such script in bash

#!/bin/bash
TEMP="/home/pi/project/temp/"
TARGET="/home/pi/project/deployed/"
cp -au $TEMP/. $TARGET

I figured out how to copy files but it takes so long time :( I my temp directory I have changed only one file and

cp -au $TEMP/. $TARGET

is coping all files and overwriting them!

Upvotes: 0

Views: 36

Answers (1)

Rod Elias
Rod Elias

Reputation: 746

rsync would be a better option.

rsync -avzpr "$TEMP" "$TARGET"

Upvotes: 3

Related Questions