Better To Move Than To Copy

Yesterday a person was copying a file, in order to change location, in this case it is a unix system, but in windows it happens the same. In this example we are going to see copy times (cp command) versus move (mv command), to see the difference. This post is designed for people who start and do not know very well the difference between copy and move. For example I have used the compressed oracle engine, but for large files you can go the time from minutes to hours.

Copying the file to another path, we see that in this case it takes almost 18 seconds;

oracle12@mortages-1:~/soft_12c_sparc$ time cp solaris.sparc64_12102_database_1of2.zip ./soft_12c_sparc

real    0m17.82s
user    0m0.00s
sys     0m4.67s

Move the same file to the same path, we see that the time is 0 seconds;

oracle12@mortages-1:~/soft_12c_sparc$ time mv solaris.sparc64_12102_database_1of2.zip ./soft_12c_sparc

real    0m0.00s
user    0m0.00s
sys     0m0.00s

The explanation is simple. The cp moves the file physically (from the first byte to the last) to the new location. With mv what we do is leave the file where it is and change in index of directories (at OS level) the logical direction that we see.

HTH – Antonio NAVARRO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s