How Do I Use 'cp' to Overwrite Files?
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?
I'm stumped as to why cp is behaving this way if there's no alias involved. However, there is a quick-dirty-and-dangerous utility provided for this exact situation: yes
. You can use it to pipe a continuous stream of affirmatives into any command that gives you confirmation prompts (you can use it to send any text, but the default is "y").
yes | cp foo bar
will execute the cp command and bypass all confirmation prompts.
It might be caused by a command alias.
To call cp
directly you can use /bin/cp src dest