当前位置:网站首页>MV command – move or rename files

MV command – move or rename files

2022-06-25 05:59:00 ProYuan28

mv The order is “move” Abbreviations of words , Its function is roughly the same as that in English , You can move files or rename them .

This is a frequently used file management command , We need to pay special attention to the difference between it and replication :mv And cp Different results .mv Commands are like files “ house-moving ”, The file name has changed , But the number has not increased . and cp The command is to copy files , The number of files has increased .

Grammar format :mv [ Parameters ]

Common parameters :

-i If there is a file with the same name , Then ask the user whether to overwrite
-f When overwriting an existing file , Without any hint
-b When a file exists , Create a backup for it before overwriting
-u When the source file is newer than the target file , Or when the target file does not exist , Move this operation

Reference examples

Will file file_1 Rename it to file_2:

[[email protected] ~]# mv file_1 file_2

Will file file Move to directory dir in :

[[email protected] ~]# mv file /dir

Put the table of contents dir1 Mobile directory dir2 in ( The premise is the directory dir2 Already exists , If it does not exist, change the name ):

[[email protected] ~]# mv /dir1 /dir2

Put the table of contents dir1 Move the files under to the current directory :

[[email protected] ~]# mv /dir1/* .
原网站

版权声明
本文为[ProYuan28]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201251057756.html