Shell Scripting Hack: cp Command With a Progress bar

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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 12 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
12 comments… add one
  • mastrboy Jan 24, 2008 @ 13:36

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

  • 🐧 nixCraft Jan 24, 2008 @ 14:02


    bar – great find!

  • unixfoo Jan 24, 2008 @ 14:31

    This is a good one ..

  • drivesoslow Jan 24, 2008 @ 16:08

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

  • Jerod Jan 24, 2008 @ 17:40


    same here 🙁

  • 🐧 nixCraft Jan 24, 2008 @ 18:15

    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

  • Jeff Schroeder Jan 24, 2008 @ 19:08


    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
  • Daemones Jan 25, 2008 @ 2:04

    How i can use this script?

  • Buddy Friend Feb 1, 2008 @ 21:54

    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!

  • leebret Jul 25, 2010 @ 20:28

    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

  • Ladislav Oct 5, 2011 @ 14:05

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

  • Aris Boch May 8, 2012 @ 13:31

    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 Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum