bug-coreutils
[Top][All Lists]
Advanced

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

RE: cp command in linux issue


From: Patrick Chin
Subject: RE: cp command in linux issue
Date: Sun, 22 Nov 2009 13:54:35 -0500

I wish there was a way to just copy files that are missing without prompting. 
Especially over a very slow connection, it would be more efficient to just do 
an update rather than prompting and overwriting implicitly.

Does anyone know what that argument is?

Thanks,

Patrick

-----Original Message-----
From: Eric Blake [mailto:address@hidden 
Sent: Sunday, November 22, 2009 10:07 AM
To: Patrick Chin
Cc: address@hidden
Subject: Re: cp command in linux issue

-----BEGIN PGP SIGNED MESSAGE-----
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.
http://www.opengroup.org/onlinepubs/9699919799/utilities/cp.html

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

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
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/

iEYEARECAAYFAksJU7EACgkQ84KuGfSFAYB1XQCeJeevEn7xsCFnHZizn/8rO74N
IzUAn2Ov+cUQfxoPlwZ0EG8wxZn4NY3u
=NWjV
-----END PGP SIGNATURE-----




reply via email to

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