Tuesday, 14 April 2009

cp with force overwrite

I was recently trying to copy a directory over an existing one and kept getting prompted - asking if I wanted to overwrite existing files - even though I was using the force option:
cp -Rf dir1 dir2
I found the answer here - it was caused by an alias forcing the interactive mode.

Quick solution is to bypass the alias by an absolute reference to cp:
/bin/cp -Rf dir1 dir2