brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pv puts a progress bar on anything you pipe

Linux
~/tips/tip-linux-pv-pipe-progress

pv backup.tar.gz | tar xz

Shows progress, speed and time left for data going through a pipe.

A long tar, dd or gzip job in a pipe gives you a blinking cursor and nothing else. I never know if it’s at 10 percent or almost done. pv (pipe viewer) fixes that: put it in the pipe and it draws a progress bar on standard error while the data flows through untouched.

pv backup.tar.gz | tar xz

Without any display switches, the man page says pv acts as if you gave it -p -t -e -r -b: a progress bar, elapsed time, ETA, current rate and bytes so far. When pv reads a file itself it knows the size, so the percentage and ETA are real.

In the middle of a pipe it can’t know the total. Give it one with -s:

tar cf - /mnt/user/appdata/<app> | pv -s 4G | gzip > app.tar.gz

Two more options I like. -L 20M caps the transfer at 20 MB per second, handy when you copy over a link you share with the rest of the house. And on Linux, pv -d <PID> watches the open files of a process that’s already running, so you can check on a copy you started without pv.

The caveat: pv usually isn’t installed by default. It’s in the normal repositories (apt install pv on Debian and Ubuntu). And the size you pass to -s is only for the maths. If you guess wrong, the bar is wrong, the data isn’t.

Further reading: pv(1) man page (Debian)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link