Sending the output from 'dd' to awk/sed/grep

The problem is your designated output from dd goes to STDERR and not STDOUT so you have to redirect STDERR as well and not only STDOUT.

For bash and zsh you can use |& instead of | which will also redirect STDERR to STDIN of the second command, e.g:

dd if=/dev/urandom of=/dev/null bs=1K count=10000 |& awk '/copied/ {print $8 " "  $9}'

The more general approach is to redirect STDERR explicitly with 2>&1, e.g:

dd if=/dev/urandom of=/dev/null bs=1K count=10000 2>&1 | awk '/copied/ {print $8 " "  $9}'

For the python part have a look at at the subprocess module and Popen in particular.


var=$(dd if=/dev/urandom of=/dev/null bs=1K count=10000 2>&1)
var=$(echo ${var##*,})