본문 바로가기

서버 | OS/Linux - Shell Script

Faster bulk(directory) copy than cp, and watch progress

It is very convenient status monitoring while copying lots number of files or large one.

Generally native linux command does not support status of copy status how much are done.

So, I found the solution through 'tar' and 'pv' utility with pipe.

tar cf - SOURCEDIR | pv | ( cd /target-dir/ ; tar xf - )

The example in the above,

  > "tar cf - SOURCEDIR" : means create a tarball copy stream to STDOUT from SOURCEDIR.

  > " | pv " : means retrive piped data and display progressive.

  > " | ( cd /target-dir/ ; tar xf - ) : means change directory to "/target-dir/" and extract retrived data from pipe input.

 

You can install the pv utility for CentOS 7.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install --disablerepo="*" --enablerepo="epel" pv