Copy not wanting to overwrite

I'm trying to copy a directory over to another location (it's a automated process), and it's using cp -Rf directory /new/directory

however, it doesn't seem to force it, it still asks if I want to overwrite it, therefore the script isn't working properly since it isn't overwriting the files.

Is there a way I can fix this?

Thanks

3 Replies

Do you have an alias setup for the cp command that includes the interactive prompts (-i or –interactive)?

$ alias

If so, remove it:

$ unalias cp

Or run the command directory from the /bin folder:

$ /bin/cp -Rf directory /new/directory

@bat:

cp -Rf directory /new/directory
Not sure if it is related to your problem, but that command will give different results depending on whether /new/directory does not exist, exists as a file, or exists as a directory. You might want to take a peek at the -t option for cp. Or even better take a look at using rsync, which IMO handles local directory copying much better than cp.

@BrianJM:

Do you have an alias setup for the cp command that includes the interactive prompts (-i or –interactive)?

$ alias

If so, remove it:

$ unalias cp

Or run the command directory from the /bin folder:

$ /bin/cp -Rf directory /new/directory

The unalias cp worked, Thanks!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct