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!mv
them orrm
them.sudo
I can usemv
orrm
to move or remove files before usingcp
. Usingsudo cp
makes no difference.