When I use
cp -R inputFolder outputFolder
the result is context-dependent:
outputFolderdoes not exist, it will be created, and the cloned folder path will be
outputFolderexists, then the clone created will be
This is horrible, because I want to create some installation script, and if the user runs it twice by mistake, he will have
outputFolder created the first time, then on the second run all the stuff will be created once again in
- I want always the first behavior: create a clone next to the original (as a sibling).
- I want to use
cpto be portable (e.g. MINGW does not have
- I checked
cp -R --parentsbut this recreates the path all the way up the directory tree (so the clone will not be
--updatein case 2 do not change anything, still things are copied into
Is there a way to do this without first checking for existence of the
outputFolder (if folder does not exist then...) or using
rm -rf outputFolder?
What is the agreed, portable UNIX way of doing that?