[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cp and mv commands (copying/moving only if file does not exist, rega
Re: cp and mv commands (copying/moving only if file does not exist, regardless of the time stamps, for use in a automatic script)
Thu, 27 Mar 2008 21:00:17 -0600
Darren DeHaven wrote:
> I need the deprecated mv and cp command parameter "--reply=" to stay.
The problem is that it never worked as desired.
> I've noticed that the parameter "--reply=no" is "deprecated"
> " cp: the --reply option is deprecated; use -i or -f instead "
Yes. See this reference for more information.
The problem is that --reply=no only had an affect when the command
would normally have prompted. In particular it had no effect when the
command would *not* have prompted. This could lead to silent data
loss. Silent data loss is very, very bad. See this message for
> My issue: In a script without user input, I want to copy a file to a
> directory if only the file doesn't already exist, (I don't want to
> overwrite anything), and regardless of the time stamp.
> The only way I see to do this is with the deprecated parameter:
> "-i --reply=no"
The solution is to use rsync instead.
$ rsync --ignore-existing foo bar
> "cp -i --reply=no foo bar"
> This way if bar exist, then foo won't overwrite it.
That is incorrect. It will overwrite the file if the input is
redirected such as when run from cron or when the input is redirected
by the user. If the input is not a tty then the command would not
normally prompt. When the command does not prompt the reply is not
used. In that case the target is overwritten.
> This message (including attachments) contains information which is
> confidential and privileged.