3

I'm testing my network speed with a script and for it to calculate average speed I need to read the speed for each run.

command:

dd if=InputFile of=OutputFile bs=4096k

output:

64+0 records in
64+0 records out
268435456 bytes (268 MB) copied, 1.8519 s, 145MB/s

the problem is that the dd command always prints the output to stdout. I can manage to pipe it or write it to file so i can read the 145MB/s

I've tried the following lines:

dd if=InputFile of=OutputFile bs=4096k >> log.txt - creates an empty file and prints to stdout

dd if=InputFile of=OutputFile bs=4096k | grep * - fails

echo `dd if=InputFile of=OutputFile bs=4096k` # fails
Itay Sela
  • 942
  • 9
  • 26

2 Answers2

4

Your problem is that dd does not print that output to stdout, but to stderr.

You have to redirect using 2> ..., for example

dd if=/dev/zero of=/dev/null count=1 2> >( grep copied )
dfogni
  • 763
  • 9
  • 14
1

You can also get the PID of the dd process and setup a watch to send a USR1 signal to your liking. Then redirect that to a file!!!!

g24l
  • 3,055
  • 15
  • 28