- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to copy with "overwrite" option
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-28-2010 11:35 PM
тАО10-28-2010 11:35 PM
I am using RedHat 5.0.
I want to copy some files into a directory and want to overwrite the files with the same name. Is there any option that suppress the messages "File exists, do you want to overwrite (Y/N)?" for each file? I tried to use cp -f option but it does not suppress the messages.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-28-2010 11:46 PM
тАО10-28-2010 11:46 PM
Re: How to copy with "overwrite" option
in this case i would recommend to use rsync or try to use : cp -avf
mikap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2010 05:03 AM
тАО10-29-2010 05:03 AM
Re: How to copy with "overwrite" option
but in most any general case where you want to answer a bunch of yes's to a series of questions, regardless of program that you're running it with, you can run the "yes" program.
$> yes | cp -f
Of course, arg1, arg2 would be whatever it is you're trying to copy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2010 05:48 AM
тАО10-29-2010 05:48 AM
Solutionalias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
To get cp with the traditional Unix behavior of not asking unless you explicitly use the -i option, run "unalias cp" to remove the alias definition.
If you always want it to behave as traditional, comment out the alias definition in your .bash_profile, .bashrc or /etc/profile (wherever it might be on your RedHat version).
NOTE: do this only if you're *really* sure you won't *ever* make typing mistakes when running as root.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2010 06:59 AM
тАО10-29-2010 06:59 AM
Re: How to copy with "overwrite" option
> definition.
Or simply bypass the alias by specifying a
path to the "cp" program. I don't know where
Red Hat actually keeps it, but I'd expect
"/bin/cp" to work.
> NOTE: do this only if [...]
Removing annoyances like this is one of the
first things I normally do when installing
a UNIX(-like) OS. I find that so-called
safety features like these tend to get
bypassed so regularly that they become
ineffective. I prefer to know what I'm
doing, and to specify "-i" when I choose to.
Aliases which add options to normal commands
(programs) are the first things which I get
rid of.
I've been doing this stuff for a while, and
I have yet to do anything like, say:
cd /
rm -r *
But I have read reports...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2010 02:53 PM
тАО10-29-2010 02:53 PM
Re: How to copy with "overwrite" option
--
$ >a
$ ls
a
$ alias cp='echo "haha, sucker"'
$ cp a b
haha, sucker a b
$ \cp a b
$ ls
a b
$
--
This bypasses the alias on a case-by-case basis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2010 12:31 AM
тАО11-01-2010 12:31 AM
Re: How to copy with "overwrite" option
As already mentioned by others you can either unalias them (type "unalias rm" in your shell, or comment out the "alias rm='rm -i' entry in ~root/.bashrc altogether and open a new subshell (just issue bash) or login again.
Other options are to give the full path to the rm command, prepend (the unpathed) rm with the word "command" (e.g. "command rm /some/file") or simply with a backslash (e.g. "\rm /some/file").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2010 12:47 AM
тАО11-02-2010 12:47 AM
Re: How to copy with "overwrite" option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 01:13 AM
тАО11-04-2010 01:13 AM
Re: How to copy with "overwrite" option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 01:13 AM
тАО11-04-2010 01:13 AM