linux中關於mv命令的運用

來源:互聯網
上載者:User

標籤:linux   移動   覆蓋   

mv  重新命名或者移動

通過which命令查看mv命令的絕對路徑,發現mv是做了別名的,實際命令是mv -i,-i的意思是詢問確認

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/66/wKiom1UH1WTxev4xAAAn5IK65og365.jpg" title="0.jpg" alt="wKiom1UH1WTxev4xAAAn5IK65og365.jpg" />

有時我們使用/bin/mv來避免詢問,  當我們mv目錄時,注意:若是目標目錄存在的情況下,那麼會把來源目錄移動到目標目錄裡
例:

建立一個目錄11

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/65/wKiom1UH1D3wgnQEAAAhcoudl5Q043.jpg" style="float:none;" title="1.png" alt="wKiom1UH1D3wgnQEAAAhcoudl5Q043.jpg" />

將/etc/11移動到/tmp,依然取名11(原本/tmp裡沒有11目錄)

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/65/wKiom1UH1D3T-ztDAAAmnIZRVEI205.jpg" title="2.png" style="float:none;" alt="wKiom1UH1D3T-ztDAAAmnIZRVEI205.jpg" />  650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

查看/tmp,此時/tmp裡有一個11的目錄

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/60/wKioL1UH1WTwjhSkAABN0maWCBg035.jpg" title="3.jpg" style="float:none;" alt="wKioL1UH1WTwjhSkAABN0maWCBg035.jpg" />  650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

再實驗

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/65/wKiom1UH1D3RvTrpAAAkdQk4kjk937.jpg" title="4.png" style="float:none;" alt="wKiom1UH1D3RvTrpAAAkdQk4kjk937.jpg" />  650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

按上述方式,將/var/11移動到/tmp,

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/60/wKioL1UH1WWTTTcrAAArfbShCU4836.jpg" title="5.png" style="float:none;" alt="wKioL1UH1WWTTTcrAAArfbShCU4836.jpg" /> 650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

/tmp裡依然有11目錄,但是沒有詢問是否覆蓋原目錄(奇怪!)

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/60/wKioL1UH1WWhAqxkAACMLIZQnRU801.jpg" title="6.png" style="float:none;" alt="wKioL1UH1WWhAqxkAACMLIZQnRU801.jpg" /> 650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

再看11目錄裡,原本空的目錄裡竟然出現了另一個11目錄,原來剛才是把/var/11移動到/tmp/11裡面了

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/65/wKiom1UH1FTzdjRKAABTeap6OCs506.jpg" title="7.png" alt="wKiom1UH1FTzdjRKAABTeap6OCs506.jpg" />

因為按上面的移動方式,會把目錄移動到指定的路徑下,即/tmp/11目錄下

正確移動方式:    650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/65/wKiom1UH1EHyGMckAAA9hNKPpIw439.jpg" title="8.png" style="float:none;" alt="wKiom1UH1EHyGMckAAA9hNKPpIw439.jpg" /> 650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="border:1px solid rgb(221,221,221);background-position:50% 50%;background-repeat:no-repeat;" alt="spacer.gif" />


linux中關於mv命令的運用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.