Add a progress bar to copy command in linux

I was looking for a way to have a progress bar when using the cp command as I move a lot of files over my LAN from my server to my Drobo, and wanted to know the transfer speeds. Since cp doesn’t have an option to show a progress bar I came across this handy modification you can make to your bash profile.

Works quite well and you now have a nice progress bar when copying files via the command line.

  • Justin

    This works well enough but I would say that overloading systems commands is *always* a bad idea. The next tool that call’s cp without specifying the full binary path is going to use rsync instead… possibly ending in disaster. I would set the alias to ‘progcp’ or something. Much safer.

    Another great tool for this is pipe viewer. Something like pv somefile > /path/to/destination/somefile works nicely. pv is also handy for any other pipe’able operation that you want to see the progress of. For example; dd if=/dev/disk/blah | pv | dd of=/path/to/dest/blah.img

    http://www.ivarch.com/programs/pv.shtml

    • Juergen Weigert

      My tool is called showspeed and it is available from https://github.com/jnweiger/showspeed

      Example:

      $ dd if=bigfile of=/tmp/otherbigfile &
      $ showspeed dd
      dd looks like a process name. pid=4417 matches av0=dd.
      p/4417/fd/0r /home/jw/bigfile 113MB/s (12%, 2.3GB) 9m:35
      p/4417/fd/1w /tmp/otherbigfile 182MB/s (2.6GB)
      p/4417/fd/0r /home/jw/bigfile 285MB/s (15%, 3.0GB) 8m:08
      p/4417/fd/0r /home/jw/bigfile 115MB/s (16%, 3.2GB) 8m:01
      p/4417/fd/0r /home/jw/bigfile 107MB/s (17%, 3.4GB) 7m:39
      p/4417/fd/1w /tmp/otherbigfile 104MB/s (3.5GB)
      p/4417/fd/0r /home/jw/bigfile 139MB/s (19%, 3.7GB) 7m:37
      p/4417/fd/0r /home/jw/bigfile 116MB/s (20%, 3.9GB) 7m:18
      p/4417/fd/1w /tmp/otherbigfile 67MB/s (4.0GB)
      p/4417/fd/1w /tmp/otherbigfile 100MB/s (4.1GB)

      • http://www.fauxzen.com/ Shelby DeNike

        Nice, I will have to give that a try. thanks!

  • http://stacklinux.com/ StackLinux

    Works thanks

    • http://www.fauxzen.com/ Shelby DeNike

      No problem, glad it worked for you.