1

I'm trying to process the realtime progress of dd, which, with pipes awareness, should be done via:

gzcat "$input" | dd bs="$block_size" count="$count" of="$output" 2>&1 | awk '/copied/ {print $1}'
gzcat "$input" | dd status=progress of="$output" 2>&1 | awk '/copied/ {print $1}'

but they don't print anything, until the end, when one line is printed.

I guess that this is because dd doesn't print any newline, therefore, awk doesn't get anything on the stdin.

Is there any workaround?

0
3

You can change AWK’s record separator to split its input on carriage returns instead of newlines:

gzcat "$input" | dd status=progress of="$output" 2>&1 | awk -v RS='\r' '/copied/ {print $1}'

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.