Linux implements no message prompt when using cp command

王林
Release: 2019-12-25 14:18:53
Original
3271 people have browsed it

Linux implements no message prompt when using cp command

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

The reason is: the server will add aliases by defaultalias cp=’cp -i’. When you execute cp, cp –i is actually executed.

[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'
Copy after login

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.

Free learning video tutorial recommendation:linux video tutorial

The following are two ways to solve this problem.

Method 1: Disable aliases

[root@ltt01 ~]# vi ~/.bashrc
Copy after login

Add "#" beforealias 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 ~]#
Copy after login

Recommended related articles and tutorials:linux tutorial

The above is the detailed content of Linux implements no message prompt when using cp command. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!