[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cp command in linux issue

From: Eric Blake
Subject: Re: cp command in linux issue
Date: Sun, 22 Nov 2009 08:07:29 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090812 Thunderbird/ Mnenhy/

Hash: SHA1

According to Patrick Chin on 11/22/2009 6:49 AM:
> If I run cp as follows:
> # cp -Rup source destination
> Why would it prompt me for overwrites since the -u is part of the argument?

Because -u has no bearing on whether prompts are asked; it only turns on a
switch to inspect the timestamps.  If the timestamps warrant a copy
attempt, then the state of the other flags determine whether a prompt is
still issued.

> I don't really want prompting to occur and just update files that don't exist 
> or is newer.

Then it sounds like you want to use -n (--no-clobber), which was added in
coreutils 7.1.

>  I also tried:
> # cp -Rupf source destination
> And I was still prompted for yes and no for overwriting.

You probably have an alias for cp that automatically includes -i, even
though it is not shown by your command line (personally, I hate aliases
that reuse the command name but turn on an option; I'd much rather give
the alias a distinct name).  But POSIX requires that cp prompt for
overwriting if -i is in effect, regardless of whether -f is also in
effect.  It takes an explicit option, like -n, to overcome -i prompting
based on POSIX rules.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]