Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    dd if=<input> | pv | dd of=<output>
to get a count of bytes passing through, or

    pv <input> | dd of=<output>
to get actual completion progress. For tarchives,

    pv <tarchive> | tar x
Compression progress

    pv <file> | bzip2 > <file>.bz2


This is also handy when using socat to pipe across a network. You can use pv on both ends, one looking at compressed and the other looking at uncompressed data, in order to observe the real-time compression ratio.

tar c foo | pv | gzip | socat - tcp-listen:9999

socat tcp:bar:9999 - | pv > foo.tar.gz

If pv shows that you aren’t saturating your network and are cpu limited, replace gzip with lzop. If vice versa, replace gzip with something more aggressive.


pv has a multi line mode so you can do

tar c foo | pv -cN raw | gzip | pv -cN compressed | whatever else

It’s handy to see multiple progress bars at once.


zstd --adapt, used to have a few rough edges though.


pv also has little known ability to watch already running process in similar fashion to progress tool

Try

cp $BIGFILE ${BIGFILE}_1 & pv --watchfd $(pidof cp)


'pv' is great, but you need to have the foresight to use it in your command before you run it. 'progress' seems great for those cases where you didn't realize your job was going to take so long, and you don't want to start it all over again.


Indeed. I created some aliases a few years ago to use pv in these cases. At least until I developed the habit of thinking about pv while composing the command.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: