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/
原文地址:https://www.cnblogs.com/shenjianping/p/13795597.html