I would like to use tee to pipe content from stdout and stderr respectively into files (in fact append it with > >(tee -a $filename)). However, instead of seeing the contents appended to the file I would like to have some real progress indicator based on the piped content. Be it the number of lines in the output on the respective channel so far, or be it the number of characters or similar.

NB: Why did I emphasize real above? Because I am aware how to get a spinning baton through a subshell in the background and later kill it by keeping its PID stored. It's a nice moving thing, but doesn't really provide any indication about what's going on - i.e. it's snake oil.

btw: At the beginning the output file may not exist, so any solution with a subshell would have to consider this.

my-program > >(pv -trabcN stdout > stdout) 2> >(pv -trabcN stderr > stderr)

Would give you a progress like:

  stderr:  123MiB 0:00:03 [42.6MiB/s] [41.1MiB/s]
  stdout:  138MiB 0:00:03 [54.2MiB/s] [46.2MiB/s]

(current (-r) and average (-a) speed. -a is relatively recent, you can omit it if your version of pv doesn't have it).

  • Awesome solution, thanks! Good old pv. Not the first time I use it, but I had no idea it was this versatile :) – 0xC0000022L Sep 18 '14 at 14:25
  • Apparently -l (aka --line-mode) is a nice option, too ... for my purpose. – 0xC0000022L Sep 18 '14 at 14:47

The -f (forever) option of the command tail might be useful.

Issuing a dot for every line of the file:

tail -f bk2ud.log | awk '{printf(".");}'

You might, however, be after something more elaborate depending on your needs..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.