Shell Scripting Hack: cp Command With a Progress bar

by on January 24, 2008 · 12 comments· LAST UPDATED January 24, 2008

in , ,

This is a nice shell scripting hack. It allows you to give a progress bar like wget to cp command.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 12 comments… read them below or add one }

1 mastrboy January 24, 2008 at 1:36 pm

great script function, i have tried something like it before called bar:


2 nixCraft January 24, 2008 at 2:02 pm


bar – great find!


3 unixfoo January 24, 2008 at 2:31 pm

This is a good one ..


4 drivesoslow January 24, 2008 at 4:08 pm

It won’t do anything for me. I try to use it and it just come right back to the prompt.


5 Jerod January 24, 2008 at 5:40 pm


same here :(


6 nixCraft January 24, 2008 at 6:15 pm

drivesoslow / Jerod ,

Open a shell prompt and just paste the code. Type the following (it will not work with wildcards)
cp_p /path/to/big/file.ext /copy/here


7 Jeff Schroeder January 24, 2008 at 7:08 pm


This is cool and all, but the overhead of strace make this not very useful. rsync -av shows a progress bar. You can also get a progress bar if you use scp locally. Yes, scp supports local file transfers without using any network or connecting to a local sshd instance.

jeff@omniscience:~$ du -h windows.tar.bz2
822M windows.tar.bz2
jeff@omniscience:~$ time cp_p windows.tar.bz2{,.new}
99% [====================================================================================================>]
real 2m18.957s
user 0m11.589s
sys 0m23.469s
jeff@omniscience:~$ ls window*
jeff@omniscience:~$ time cp windows.tar.bz2{,.new2}
real 1m39.597s
user 0m0.096s
sys 0m5.092s


8 Daemones January 25, 2008 at 2:04 am

How i can use this script?


9 Buddy Friend February 1, 2008 at 9:54 pm

LOL at the nubs who can’t get this to work. Go back to your Vista box and stay there.

Only thing I had to do was set my terminal to ANSI. Also, the width of this progress bar is fixed, it will not scale with the width of your terminal.

Also note that for trivial transfers they might complete before the script has a chance to output the progress bar. So if the file copies and you didn’t see a progress bar, it’s because you didn’t need one.

yes scp and rsync are alternatives but this is very cool nonetheless. Thank you for posting it!


10 leebret July 25, 2010 at 8:28 pm

Altho my system didn’t support bar I did find pipeview (pv):


tar -Ocf – $srcdir | pv -i 1 -w 50 -berps `du -bs $srcdir | awk ‘{print $1}’` |
7za a -si $outfile


11 Ladislav October 5, 2011 at 2:05 pm

take a look at freebsd utils Successfully compiled on Redhat 5.7.


12 Aris Boch May 8, 2012 at 1:31 pm

This script doen’t work… And what is it for anyway, rsync does the same job without all this mumbo-jumbo of arkward custom scripts.


Leave a Comment

Tagged as: , ,

Previous post:

Next post: