Linux - mv 命令

查看帮助信息

# mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     display this help and exit
      --version  output version information and exit

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/mv>
or available locally via: info '(coreutils) mv invocation'

将文件夹移动至某个目录下

当前工作目录下待移动文件夹:

# ll
drwxr-xr-x  6 1001 1001     4096 1月   7 20:24 node-v12.14.1-linux-x64/

目标目录:

# ll /opt/
total 8
drwxr-xr-x  2 root root 4096 8月   6 02:58 ./
drwxr-xr-x 24 root root 4096 1月  23 16:16 ../

node-v12.14.1-linux-x64 移动到 /opt/ 目录下:

# mv -i node-v12.14.1-linux-x64 /opt/

移动后:

# ll /opt/
total 12
drwxr-xr-x  3 root root 4096 2月   2 22:56 ./
drwxr-xr-x 24 root root 4096 1月  23 16:16 ../
drwxr-xr-x  6 1001 1001 4096 1月   7 20:24 node-v12.14.1-linux-x64/
发布了55 篇原创文章 · 获赞 0 · 访问量 3185

猜你喜欢

转载自blog.csdn.net/qq_29761395/article/details/104150823