Reputation: 1722
If you want to move a file from one directory to another you can use either of the commands mv
or cp
. But what is the difference between the two, and when should one be used over the other?
Upvotes: 3
Views: 20881
Reputation: 21
mv
moves or renames a file or directory, while cp
copies a file or directory.
mv
deletes the source file or directory after moving it, while cp
keeps the source file or directory intact.
mv
does not change the inode number of the file or directory, while cp
creates a new inode number for the copied file or directory.
mv
does not access the file or directory data if the destination is on the same filesystem, while cp
always reads and copies the file or directory data.
Upvotes: 2
Reputation: 154
The cp
command will copy your file(s) while the mv
one will move them.
So, the difference is that cp
will keep the old file(s) while mv
won't.
Upvotes: 9