cv: progress bar for cp, mv, rm, dd…

One of our earlier articles explores tools on Linux to view the progress of commands like cp and mv. Coreutils Viewer (cv) is a utility that takes it to the next level by adding support for commands like rm, dd and even the progress of browser downloads.

cv supports all basic utilities in coreutils package. It is written in C and shows the progress as percentage. cv works by scanning /proc for commands that it supports, checks directories fd and fdinfo for opened files and seek positions and finally reports the progress for the largest file.

List of supported commands:

cp mv dd tar gzip gunzip cat grep fgrep egrep cut sort xz md5sum sha1sum sha224sum sha256sum sha384sum sha512sum

The author has plans to support the following:

  • Progress bar
  • Estimated time
  • top-like mode with more accuracy

Installation

Run the following commands to compile and install cv:

$ git clone https://github.com/Xfennec/cv.git
$ cd cv
$ make
$ sudo make install

Usage

  • Run cv
    $ cv
  • Monitor all current and upcoming instances ofcoreutils commands in a simple window
    $ watch cv -q
  • See Firefox download progress
    $ watch cv -wc firefox
  • Look at your Web server activity
    $ cv -c httpd
  • Launch andmonitor any heavy command using $!
    $ cp bigfile newfile & cv -mp $!

Available options:

Syntax: cv [-qdwmM] [-W secs] [-c command] [-p pid]
-q --quiet              hides all messages
-d --debug              shows all warning/error messages
-w --wait               estimate I/O throughput and ETA (slower display)
-W --wait-delay secs    wait 'secs' seconds for I/O estimation (implies -w, default=1.0)
-m --monitor            loop while monitored processes are still running
-M --monitor-continous  like monitor but never stop (similar to watch ./cv)
-c --command cmd        monitor only this command name (ex: firefox)
-p --pid id             monitor only this process ID (ex: `pidof firefox`)
-v --version            show program version and exit
-h --help               display this help and exit

On GitHub: Coreutils Viewer

Similar software

pv

Pipe Viewer (pv) is a similar utility which can be used to monitor the progress of data through a pipeline. It gives a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. pv works for two processes at a time.

Webpage: Pipe Viewer

4 thoughts on “cv: progress bar for cp, mv, rm, dd…”

  1. It seems the user has to install libncurses5-dev before compiling this (on Debian/Ubuntu).

    This tool is useful, although it would be more practical if they had created wrappers around tools like cp and mv instead. I have placed this function in my .bashrc as a wrapper for cv:

    __cv(){
    “$@” &
    local pid=$!
    trap “kill $pid &>/dev/null ||:” RETURN

    cv -mp $pid
    }

    And then use aliases in .bashrc for the commands you want to use cv by default. Examples:
    alias cp=’__cv cp’
    alias mv=’__cv mv’

    So now you can just run `cp bigfile newfile’ and cv will always display the progress, although it will run for small files too, but then the function would have to check the sizes of the files beforehand.

    Another approach would be calling it only when you want, like “ccp” for cp, and “cmv” for mv:
    alias ccp=’__cv cp’
    alias cmv=’__cv mv’

    1. I guess I had it installed so didn’t face any issues with compilation.
      Yes, creating wrappers using alias is convenient.
      I’m sure the information will help other readers! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *