Using the Copy command CP under Linux, do not let the "overwrite" (file overwrite) prompt method appear.

Source: Internet
Author: User

Using the Copy command CP under Linux, do not let the "overwrite" (file overwrite) prompt method appear.

In general we use the CP command with the-f option, and I hope we don't let the "overwrite" prompt (the hint of file overwrite) appear. Such as:
# CP-RF SourceFile TARGETDIR
Or
#cp-R-F sourcefile targetdir
-R means recursive replication, that is, copying the folder and all of its files.
-F means that you are not prompted when you encounter a file of the same name, overwriting directly.

But why add-F, but also the "overwrite" hint?

This is because the system prevents us from accidentally overwriting a file that should not be overwritten, and uses the alias of the command. Use the alias command to see:
# Alias
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 '

From the top we can see that the CP command we entered is actually the "cp-i" command. Several other commands, such as Ll,ls mv,rm, also use aliases.

The first of these solutions:
Adding a "\" symbol to the CP does not run with an alias, as follows:
# \cp-f SourceFile TARGETDIR
The second solution:
Edit the file and comment out the alias.
# VI ~/.BASHRC
In alias cp= ' Cp-i ' before adding "#" comment off this line, wq! save the launch, and then re-login on it.

Transferred from: http://blog.csdn.net/iw1210/article/details/46550707

Using the Copy command CP under Linux, do not let the "overwrite" (file overwrite) prompt method appear. Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.