How to make CP command not prompt overwrite under Linux

Source: Internet
Author: User
Tags aliases

Use the CP command under Linux, often prompt whether to overwrite, if is too batch of file overwrite, always so prompt, will be very annoying. So how do we solve this problem?

Let's look at the reasons first!

Generally we use the command is 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 to encounter files with the same name, without prompting, directly overwriting

But why do we use these two parameters, the system will still prompt to overwrite it?

This is because the system uses aliases when installing, which prevents us from accidentally overwriting files that should not be overwritten. You can see the specific configuration using the alias command.

[[email protected] home]# 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 '
Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '

From the top we can see that the CP command we entered is actually the "cp-i" command,

That is, no matter how we enter CP-RF, in fact, the implementation is Cp-i-RF, it is no wonder that always asked whether the cover.

From the above command we can know that several other commands, also used aliases, such as Ll,ls mv,rm.

So how do we solve this problem?

[Email protected] home]# VI ~/.BASHRC
#. BASHRC

# User specific aliases and functions

Alias rm= ' Rm-i '
Alias cp= ' Cp-i '
Alias mv= ' Mv-i '

# Source Global Definitions
if [-F/ETC/BASHRC]; Then
. /etc/bashrc
Fi
You can comment out the command by adding the # number before the corresponding command. Save the exit and then you can use the Pure original command.

In fact, there is a way to solve this problem, is to use the \cp-f file dir on it!

How to make CP command not prompt overwrite under Linux

Related Article

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.