Does cp -a refresh existing files, overwrite or skip
Solution 1
cp will overwrite all files.
what you are looking for if you do not want that behavior is the rsync command.
the -a option just means it will preserve the source file metadata, like creation time, owner, access mode and such..
Solution 2
Existing files will be over-written, as somewhat implied in gilles' answer to Difference between cp -r and cp -a.
Related videos on Youtube
![Fat Monk](https://i.stack.imgur.com/d6pLD.png?s=256&g=1)
Fat Monk
Pooters: Been developing for web since 1993 (HTML, PHP, JavaScript etc). Also dabble in Free pascal and previously C++ via C++ Builder. Running Windows and Linux. A bit of Android dev in Java with a couple of apps in the Play Store. Other: Private Pilot, sliding on snow, video editing and graphics. Creations - Web: BlueBadgeParking.com, CumbrianDictionary.co.uk, GonMad.co.uk, NoOriginalThought.com Creations - App: AmALfi - Amazon Affiliate Link Creator, YABS - Yet Another Bill Splitter, Blue Badge Parking
Updated on September 18, 2022Comments
-
Fat Monk almost 2 years
If I use
cp
in archive mode e.gcp -a /my_old_directory/* /new_location/my_new_directory/
to replicate a directory structure and all that is in it.
If I then run the same command again will any changed files be refreshed or over-written or skipped?
(I know
rsync
is more advanced at this kind of thing, I'm just curious aboutcp -a
as I can't find any description of what it actually does in this case.