cp command problems forcing overwrite using cp command

Mobile
feeds
Welcome Login | Register

cp command problems forcing overwrite using cp command
Reply Your Comments:
Click this button if you are interested in replying to this topic and leave your comments
Sent To Friend
CLick this button if you want to send this page to a friend.
Subsribe To Rss Feeds
Subscribe to RSS
CLick this button if you want to subscribe to this RSS Feed. You can use your browsers feeds burners if you have mozilla or internet explorer 7 or higher and keep up with updates.
  Forums Index
      » Linux Forums
        » » cp command problems forcing overwrite using cp command
cp command problems forcing overwrite using cp command
Post Description: cp command problems forcing overwrite using cp command Linux
Post Tags:
This Post Has Been Viewed 2892 Times Since Fri Jan 25, 2008 3:37 pm Author hostman with 7 replies
Next Post »» linux shell script varirable command sample
cp command problems forcing overwrite using cp command
Advertise On This Page




today i was trying to copy a many files and when i send this command:

Command:

cp -rf /this/file /to/this/file


i get this prompts:

Command:

cp: overwrite '/this/file /to/this/file' ?


when i look at the man pages for cp it says:

-f, --force
if an existing destination file cannot be opened, remove it and
try again


so it shouldn't ask me, so i found out that de defaults on the dedicated linux server we got from www.webune.com has cp as alias. so if you having this same problem, then run this command to see your alias:

Command:
alias


OUTPUT:
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

as you can see, i do have an alias with cp

so how do you overwrite without prompt?
what i need to do is remove that cp alias witht he unalias command so i send this coommand:
Command:
unalias cp


so now when you do the alias command, you wont see the cp alias anymore

so what happens if your not the admin or dont have access to root, then you can run an unaliased cp command, try

Command:
$ /bin/cp -rf /this/file /to/this/file


hope this helps..

thanks for the guys at www.webune.com for their support on this question




Leave Your Comments
Your Name
Your Email Address (Will Not Be Published)
Your Comments

Share:   Subscribe - Keep Up With This Topic
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites
URL:
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
Fourms BBCODE:
Links Related to : cp command problems forcing overwrite using cp command
Add Link:

Comments and replies About cp command problems forcing overwrite using cp command
:: 1 :: Reply #38170 Reply By copy On Fri Jan 25, 2008 3:39 pm
copy:
i recommend that isp's or unix systems with users who may be unfamiliar with unix setup the following aliases:

clr clear
cls clear
copy cp -i
del rm -i
delete rm -i
dir ls -alg
home cd ~
ls ls -f
md mkdir
move mv -i
pwd echo $cwd
type more
:: 2 :: Reply #70774 Reply By Osman On Tue Sep 16, 2008 2:44 am
Osman:
it did helped. thank you
:: 3 :: Reply #89275 Reply By Chad On Thu Jan 08, 2009 1:53 pm
Chad:
i was wondering why the silly box kept insisting on permission to 'cp' everything! thank you ever so much for the great tip!
:: 4 :: Reply #97273 Reply By Dany On Mon Mar 16, 2009 1:44 am
Dany:
or you can use \ in front of cp -f <source> <destination> command which will temporarly disable the alias.
:: 5 :: Reply #105014 Reply By Fletch On Mon Jun 01, 2009 11:25 am
Fletch:
or

yes n | cp -rf
:: 6 :: Reply #119436 Reply By Sia On Tue Nov 03, 2009 5:14 am
Sia:
nice one, thanks for that. pretty sure debian doesn't have tha alias by default. i'm kinda new to centos, and this was bothering me.
:: 7 :: Reply #126719 Reply By os3009 On Mon Jan 25, 2010 10:37 pm
os3009:
thanks.. very useful tip
i tried every step and worked fine