linux下面覆蓋檔案,如何?直接覆蓋,不提示

來源:互聯網
上載者:User

標籤:blog   http   檔案   sp   問題   on   c   log   linux   

轉自:http://w-tingsheng.blog.163.com/blog/static/2505603420124309130528/

  cp覆蓋時,無論加什麼參數-f之類的還是提示是否覆蓋,當檔案比較少的時候還可以按Y確認,當很多檔案的時候就不好說了。用下面的方法可以解決覆蓋提示的問題。

例如:把zongguofeng目錄下的檔案複製到linuxzgf目錄
    
[[email protected] ~]# cp zongguofeng/* linuxzgf
cp:是否覆蓋“linuxzgf/1.txt”? 
    執行上面的命令時,linuxzgf檔案夾中存在的每個檔案都會提示是否覆蓋;
    
  [[email protected] ~]# cp -rf zongguofeng/* linuxzgf
cp:是否覆蓋“linuxzgf/1.txt”? 
  加了-f了,依然有此提示。

伺服器上尋找後發現在預設的系統中是加了別名如下
[[email protected] ~]# alias 
alias cp=‘cp -i‘
可以看到別人  ,也就是當執行cp的時候,其實執行的是cp -i參數


解決辦法:

方法一:修改bashrc檔案禁用掉cp的alias

[[email protected] ~]# vi ~/.bashrc        
    
  在alias cp=‘cp -i‘前加上"#"注釋,重新登入即可實現複製不提示。

[[email protected] ~]# cp -rf zongguofeng linuxzgf
[[email protected] ~]# cp -r zongguofeng linuxzgf


方法二:直接輸入命令即可實現

[[email protected] ~]# cp -rf zongguofeng linuxzgf/
cp:是否覆蓋“linuxzgf/zongguofeng/user_add.sh”?

[[email protected] ~]# \cp -rf zongguofeng linuxzgf
[[email protected] ~]#

linux下面覆蓋檔案,如何?直接覆蓋,不提示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.