redirect output from dd command

Posted on

Problem :

How to redirect output from dd command to /dev/null ?

Solution :

If you want to redirect the data output, use the of argument:

dd if=/dev/urandom of=/dev/null count=1

If you want to redirect both the data output and the progress messages:

dd if=/dev/urandom count=1 >/dev/null 2>&1

If you want to save the data and throw away the messages:

dd if=/dev/urandom of=output_file count=1 2>/dev/null

In these examples /dev/urandom and the count argument are simply being used for demonstration.

By default dd sends what it read from if to stdout, but usually (always?) one wants to redirect it to a file. Use the of parameter for that.

dd if=from of=to

So you want to replace to with /dev/null.

Leave a Reply

Your email address will not be published. Required fields are marked *