Linux mv command

mv is the abbreviation of move, which is used to move files or rename files.

Command format:

mv [options] source file destination file
  1. The target directory is the same as the original directory, and a new file name is specified, and the effect is just to rename. (./ represents the current directory)

[root@localhost text]# ls
1.txt  2.txt
[root@localhost text]# mv ./1.txt  ./3.txt
[root@localhost text]# ls
2.txt  3.txt
  1. The destination directory is inconsistent with the original directory, no new file name is specified, the effect is just to move.

[root@localhost text]# ls
2.txt  3.txt  text2
[root@localhost text]# mv ./2.txt ./text2/
[root@localhost text]# ls
3.txt  text2
[root@localhost text]# ls text2/
2.txt
  1. The target directory is the same as the original directory, and a new file name is specified, the effect is: move + rename.

[root@localhost text]# ls
3.txt  text2
[root@localhost text]# mv ./3.txt ./text2/4.txt
[root@localhost text]# ls
text2
[root@localhost text]# ls text2/
2.txt  4.txt

Guess you like

Origin blog.csdn.net/zheng_long_/article/details/129398359