宇筱博客

  • 解决办法
  • 学无止境
  • 记录时光
  • 百宝箱
宇筱博客
点滴记忆,汇聚成海。
  1. 首页
  2. 解决办法
  3. 正文

Linux下cp -rf总是提示覆盖的解决办法

2022年1月29日 752点热度 0人点赞 0条评论

通常情况下使用cp -rf进行文件或者文件夹的管理时一般就不再提醒是否覆盖。然而在内网的一台机器上使用cp -rf却提示是否覆盖。难道和常用的命令不同?

[root@xxxx test]# cp -rf ./files/ ./bak/
cp:是否覆盖"./bak/files/test.txt"? 
cp:是否覆盖"./bak/files/hh.txt"? 
cp:是否覆盖"./bak/files/child/child.txt"?

后来发现是别名引起的问题。

[root@xxxx test]# 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命令,其实是执行了cp -i命令的别名,因此无论怎么输入都提示是否覆盖。

修改~/.bashrc,在“alias cp='cp -i'”前添加#号注释后即可。

[root@xxxx test]# 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

 让命令生效:

source ~/.bashrc

 或者重启即可。

原文链接:https://www.cnblogs.com/rwxwsblog/p/5662919.html

标签: 暂无
最后更新:2022年1月29日

小渔民

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2025 宇筱博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15017825号-2