一、用法
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/