Using a shell script or Terminal, how do I overwrite files that may or may not be present. I looked at man page for cp, it said use the -f argument to force overwrite. But, it does nothing.
$ cp -f /path/to/source/file.txt /path/to/target
Or is there another option to overwrite files using the common in-built command line tools in OS X?
sudo
at the beginning of the command. But use with caution! – Daniel♦ Dec 6 '13 at 1:36mv
them orrm
them. – rogerFernand Dec 10 '13 at 18:50sudo
I can usemv
orrm
to move or remove files before usingcp
. Usingsudo cp
makes no difference. – rogerFernand Dec 10 '13 at 18:54