Feb 052010

I recently copied an entire directory to a folder and during the cp (copy), but some of the files were changed/modified during the cp. I went to re-copy the files again and was struck with the inevitable “do you want to over write this file…?” 19,000,000 times… I did a Ctrl+C to stop the operation and went to my bestest bud in the universe when I can’t find something, Google, and came across this little tidbit of information.

There’s a reason why cp (copy) is aliased to cp -i in /root’s .bashrc and .cshrc/.tcshrc file. After all, do you really want root to be able to overwrite a file without checking? There is a way around the problem that retains the copy protections in root’s shell. Here’s how:

\cp -f <filename> <path/to/existing_file>

Backslashing the cp command temporarily disables the alias mentioned in the shells .bashrc, but does not permanently remove the protection. Enjoy!

 Posted by at 6:18 am