2

I use the following command to copy a folder (named 'dist') containing a react project to my frontend folder:

cd apps/react-app
sudo cp -R dist ../server/frontend/client

The first time I run the 'cp'-command, the content of the 'dist'-folder gets copied into the 'client'-folder. I would expect that when I run this command again, the cp-command would overwrite the files in the 'client'-folder. This doesn't happen, instead, the 'cp'-command now creates a 'dist'-folder inside the 'client'-folder en puts all the new files in there. The 3th, 4th, ... time I run the 'cp'-command, it overwrites all the files in the 'dist'-folder, but the files from the first 'cp'-command are still in the 'client'-folder also.

How can I cp the files from the 'dist'-folder to the 'client'-folder, and whenever I run this command again, it overwrites (instead of creating a new folder)?

Sam Leurs
  • 121

1 Answers1

0

Yes, cp overwrites. It is idempotent.

The first time I run the 'cp'-command, the content of the 'dist'-folder gets copied into the 'client'-folder.

Are you sure? Normally, the folder itself should be copied (including its content), and indeed that is want you see in the next runs.

How can I cp the files from the 'dist'-folder to the 'client'-folder,

With

cp -r dist/* client