Tuesday, October 2, 2012

[Linux] Copy files faster cp command

Every Linux user is familiar with file copy command, cp (copy). As an user who uses this frequently in a day, I can't help but wonder about possible alternatives to cp. CP is terrible when copying large number of files that are small in size. So, after digging in the internet, I found the following command to be a little more faster than cp command when it comes to copying smaller files.

tar cf - dir1 | (cd dir2; tar xf -)

With this, you can move an entire directory from dir1 to dir2. Here's an example.

tar cf - images/ | (cd /media/gentoo_/images/ tar xf -)