mv命令詳解


一、用法

mv命令有兩大主要功能:

  • 移動源文件或者到另一個目錄
  • 源文件或者目錄進行重命名

主要參數詳解:

       -f, --force #強制執行,不會詢問
              do not prompt before overwriting

       -i, --interactive #如果目標文件存在,詢問是否覆蓋
              prompt before overwrite
              
       -u, --update #若目標文件存在,當源文件比目標文件新才會移動
              move  only  when the SOURCE file is newer than the destination file or
              when the destination file is missing

# 注意如果源文件是多個,那么目標是目錄

二、實戰

# 把test1移到test2目錄中
[root@localhost project]# mv test1 test2

# test2重命名為test3
[root@localhost project]# ll
total 0
drwxr-xr-x. 3 root root 19 Oct 10 21:59 test2
[root@localhost project]# mv test2 test3
[root@localhost project]# ll
total 0
drwxr-xr-x. 3 root root 19 Oct 10 21:59 test3

# 多個文件移動到目錄中
[root@localhost project]# mv t1.txt t2.txt test3/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM