4

Executing this command displays the output on console. But when output is piped to another command it does not work. See below.

(pv -F $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) 
0:00:01 [25.2MiB/s] ETA 0:00:18
0:00:02 [23.7MiB/s] ETA 0:00:18
0:00:03 [ 100MiB/s] ETA 0:00:07
0:00:04 [ 199MiB/s] ETA 0:00:01

Now see below same command output is piped to another command and it does not display anything at all. I have redirected stderr to stdout and passed it to tr -d so it can remove ":[ ] " characters.

(pv -F $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) 2>&1 | tr -d ':[]'

See below, same command, but I am not redirecting stderr to stdout, Also if I don't redirect stderr to stdout, with the same command above, I don't get desired results, see below, using tr -d to delete following characters ":[]" but does not work. You can see tr -d command is completely ignored.

(pv -F $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) | tr -d ':[]'
0:00:01 [25.2MiB/s] ETA 0:00:18
0:00:02 [23.7MiB/s] ETA 0:00:18
0:00:03 [ 100MiB/s] ETA 0:00:07
0:00:04 [ 199MiB/s] ETA 0:00:01

I have spent countless hours to figure this out, searched on stackexchange and all the forums but I cannot get my head around, how to fix this.

I have also tried using file Descriptor 2>&3 but still no luck.

1 Answer 1

6

Use pv -f …

From man 1 pv:

-f, --force
Force output. Normally, pv will not output any visual display if standard error is not a terminal. This option forces it to do so.

(pv -fF $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) 2>&1 | tr -d ':[]'
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.