Home >Operation and Maintenance >Linux Operation and Maintenance >What should I do if I still get a prompt when setting rf in cp in Linux?

What should I do if I still get a prompt when setting rf in cp in Linux?

WBOY
WBOYOriginal
2022-07-20 16:47:502730browse

There are two solutions: 1. Use "vi ~/.bashrc" to modify the "/.bashrc" file, and add "#" before "alias cp='cp -i'" to comment it Just delete it, save and exit, and then log in again; 2. When using the cp command, add "\" before "cp" to remove the prompt.

What should I do if I still get a prompt when setting rf in cp in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What should I do if the rf setting in Linux still prompts?

By default, when cp overwrites, no matter what parameters -f or the like are added, it still prompts whether to overwrite.

The reason is: The server will add the alias alias cp=’cp -i’ by default. When you execute cp, it actually executes cp -i.

[root@ltt01 ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

cp cancels the prompt information and directly overwrites it. The user does not need to hit y to interact, which is very important when the script is executed.

The following are two ways to solve this problem.

Method 1: Disable aliases

[root@ltt01 ~]# vi ~/.bashrc

Add "#" before alias cp='cp -i' to comment out this OK, :wq! Save and exit, then log in again.

Method 2: Add \ before cp

[root@ltt01 ~]# \cp 1.txt /back/1.txt 
[root@ltt01 ~]#

What should I do if I still get a prompt when setting rf in cp in Linux?

Recommended learning: Linux video tutorial

The above is the detailed content of What should I do if I still get a prompt when setting rf in cp in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn