Search code examples
linuxshelldd

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


In shell script i need to redirect output from dd command to /dev/null - how to do that?

( dd if=/dev/zero of=1.txt count=1 ) 2>&1 /dev/null

didn't work!


Solution

  • If you want to redirect only the standard output of the command do:

    ( dd if=/dev/zero of=1.txt count=1 ) > /dev/null
    

    and if you want to redirect both stdout and stderr to /dev/null do:

    ( dd if=/dev/zero of=1.txt count=1 ) > /dev/null 2>&1