Hi,
How can i copy a file to another with the same name without being prompted for a confirmation ?
I read the cp man page, but nada.
Any help would be appreciated.
Warm Regards, Mário Gamito
How can i copy a file to another with the same name without being prompted for a confirmation ?
-f should allow you to do this. For root, cp is aliased to cp -i, so you can either set the alias the way you want, or you can do '\cp foo bar' without the ticks, which tells the system to ignore the alias for the command.
Any help would be appreciated.
No applause, just throw money. :-P
I have used the -f flag and it never seems to work for me; I still get prompted.
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org] On Behalf Of mouss Sent: Friday, March 02, 2007 7:04 PM To: CentOS mailing list Subject: Re: [CentOS] Lame question about cp
Mário Gamito wrote:
Hi,
How can i copy a file to another with the same name without being prompted for a confirmation ?
I read the cp man page, but nada.
1. # /bin/cp foo bar
2. # cp -f foo bar
3. # \cp foo bar
4. # unalias cp # cp foo bar
... _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Mario (?) wrote:
How can i copy a file to another with the same name without being prompted for a confirmation, and -f doesn't work?
Unalias cp doesn't work....hmmm.
If it is still not working, workaround it by using this:
rm /dir/foobar touch /dir/foobar cp /source/foobar /dir/foobar
Nothing fancy, but it should accomplish the same task.
Best,
Pkrash, dealing with upcoming DST features In our house. Not CentOS related heads up: Juniper firmware updates for multiple devices Breaks RSA backend Xauth. (SSG5, SA2000, NetScreen25, etc....)
Centoss Related: RH5 coming soon :-) This e-mail and any documents accompanying it may contain legally privileged and/or confidential information belonging to Exegy, Inc. Such information may be protected from disclosure by law. The information is intended for use by only the addressee. If you are not the intended recipient, you are hereby notified that any disclosure or use of the information is strictly prohibited. If you have received this e-mail in error, please immediately contact the sender by e-mail or phone regarding instructions for return or destruction and do not use or disclose the content to others.
Paul Krash wrote:
Mario (?) wrote:
How can i copy a file to another with the same name without being prompted for a confirmation, and -f doesn't work?
Unalias cp doesn't work....hmmm.
How about
$ which cp
He may have some script sth.
Mike
Hi,
How can i copy a file to another with the same name without being prompted for a confirmation ?
Hello, Mario.
Type this: # alias This should show you the current alias for the cp command. I personnally have this: alias cp='cp -i'
The -i option requires the user confirmation for each copied file. This is for safety concerns. Therefore, if this is also your case, you need to add the --reply=yes option so that it automatically answers yes to all questions. Therefore you would type: cp --reply=yes ./myfile ./myfile2 and if myfile2 existed it shouldn't ask any confirmation. However, this '-i' cp alias command should only be there for any user shell (even root), but should not be there for any cron script or use outside of a shell command, so the -f would be sufficient in this case.
However, putting 'unalias cp', and then 'cp -f' should do in your case also, and I don't understand why it doesn't..
Hope it helps. Daniel
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Fri, Mar 02, 2007 at 08:09:29PM +0000, Mário Gamito wrote:
Hi,
How can i copy a file to another with the same name without being prompted for a confirmation ?
I read the cp man page, but nada.
Any help would be appreciated.
I have seen a lot of sensible advice, but you reported none worked, which is odd.
Just for the sake of curiority, what is the output of:
# type cp
?
[]s
- -- Rodrigo Barbosa "Quid quid Latine dictum sit, altum viditur" "Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org] On Behalf Of Mário Gamito Sent: Sunday, March 04, 2007 6:17 AM To: CentOS mailing list Subject: Re: [CentOS] Lame question about cp
Hi,
I have seen a lot of sensible advice, but you reported none worked, which is odd.
Nothing worked :(
Only removing the alias, which is a thing i don't want to do.
Warm Regards, Mário Gamito _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
if you don't want to remove the alias use:
/bin/cp foo foo1
or, if that doesn't work (which it works for me), use:
/bin/cp -f foo foo1
Both of these have been recommended already and should work. This does not work?
Specifying the /bin path says for this execution only, do not use the aliased version.
Michael
On Sun, March 4, 2007 04:17, Mário Gamito wrote:
Hi,
I have seen a lot of sensible advice, but you reported none worked, which is odd.
Nothing worked :(
Only removing the alias, which is a thing i don't want to do.
Hello,
I'm new to the list and this thread. I apologize if this has been mentioned before. If you are using bash you can temorarily 'unalias' a command by sticking a \ in front of the command:
\cp \ssh \rm \mv
It can be a big time saver. Another thing you can do is create a new alias that has saftey features off:
alias cpf="/bin/cp -f";
As far as I am aware if you do a cp -p then adding a -f isn't going to work. That is essentially what is happening. If cp sees the -p flag, it is going to prompt as a matter of saftey. I think several other util commands do the same thing.
Good luck, -Ryan Simpkins
-Ryan