mv 和 rename的區別和Linux C實現

1. mv 和 rename的區別
(1) rename可以批量重命名, 而mv一般單個重命名
(2) mv命令可以處理源文件和目標文件在不同file system的情況[1], rename可能不行.(Don't forget that 'mv' does considerably more than 'rename()' when the source and target locations are on different file systems.)
(3) The mv command changes the pointer to the file not the file itself. However, if the destination is on another file system (NFS mount are included here) a copy operation occurs first.
In other words, if you are moving a file from one file system to another, the file is actually copied. If you are moving the file within the same filesystem, the pointer to the file is changed but the data stays in place.[2]
2. mv和 rename在C下實現方式
(1) man 2 rename
(2)system("mv source dest")


Reference
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章