Everywhere I read the following description.

-i, --interactive :::::::Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files.

but I am not able to understand why the term overwriting is used here. If I am copying a directory to another directory, then what is overwriting here?

Somebody please explain me the use of cp -i with an example.

  • 2
    this sounds like a homework question. regardless, just try it, cp a file to somewhere new, or where it already exists... – guiverc May 6 '18 at 5:14

The word overwriting is used while we are copying a file/folder to somewhere it already exist. Lets say we have two folders folder1 and folder2, each one of them containing a file named file.txt So, if we try to copy the contents of folder1 to folder2 using cp -i command, it will ask us to confirm overwriting because the same file already exist there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.