Linux uses MV command to rename or move files

Time:2021-3-5

usage method:

$ mv --help
Usage: MV [options]... [- t] source target
     MV [option]... Source... Target
Rename or move files / directories.

The parameters that long options must use are also required for short options.
  -B similar to -- backup option, but does not accept parameters, backup before overlay
  -f. -- force direct coverage without query interaction
  -i. -- interactive query interaction before covering
  -n. -- no clobber does not cover existing files
  -u. -- update move only when the source file is newer than the target file or the target file does not exist
  -v. -- verb output file features before each output file is opened

Use example:

#Rename file
mv file1.log test1.txt

#Move files to directory
mv file1 tmp/

#Move multiple files
mv log1.txt log2.txt log3.txt tmp/

#Move all files in the directory to another directory
mv dir1/ /tmp/dir2

#Interactive overlay file
mv -i log1.txt log2.txt

#Backup the file before covering and read the environment variable version_ Control as a backup strategy
mv -b log1.txt log2.txt

#Force overlay file
mv -f log3.txt log2.txt

#If dir2 does not exist, rename the directory; if dir2 already exists, put dir1 into dir2 directory
mv dir1 dir2

#Move all the files in the current folder to the upper directory
mv * ../

#Move files from one subdirectory of the current directory to another
mv test3/*.txt test5/