:: Re: [DNG] OT: redirecting piped / p…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Ludovic Bellière
Fecha:  
A: Florian Zieboll
Cc: [DNG]
Asunto: Re: [DNG] OT: redirecting piped / processed stderr to a file
Hello Florian,

The output isn't going anywhere, it's simply being buffered. It's a
default when a tool doesn't specify buffering behavior for stdout. In a
chained pipe, the output will only start being sent once the buffer gets
full. That is to avoid heavy use of resources in case the tasks involved
are verbose.

You can change that behavior by using `unbuffer` or `stdbuff`. Check the
man pages for more information.

Cheers,
                 Ludovic


On Mon, 14 Mar 2022, Florian Zieboll via Dng wrote:

>Hallo list,
>
>may I ask for support with redirecting piped / processed stderr to a file?
>
>dd prints it's progress to stderr, I can redirect it to a file:
>$ dd if=/dev/zero of=./zeroes bs=4M count=1000 status=progress 2> ./file
>
>Now I want to get rid of the CR and can print to the console as expected:
>$ dd if=/dev/zero of=./zeroes bs=4M count=1000 status=progress 2>&1 | tr '\r' '\n'
>
>But if I redirect tr's output to a file (or pipe it otherwise), it "disappears": Empty console and empty file.
>$ dd if=/dev/zero of=./zeroes bs=4M count=1000 status=progress 2>&1 | tr '\r' '\n' > ./file
>
>Where is it going resp. how do I catch it?
>
>Thanks a lot in advance!
>Florian