How to force cp command to overwrite without confirmation?

You can use cp -rf option to forcefully overwrite the destination file if already exists.

Example:

Create some files and directories:

Force cp command to overwrite without confirmation:

if you still getting prompts that means somewhere an alias has been defined for cp with cp -i. In this case, directly execute the cp binary with -rf option

Leave a Reply