/dev/null
In this page:
/dev/null
/dev/null is a special file that discards anything written to it, commonly used to silence output you don't care about. Redirecting both streams there, command > /dev/null 2>&1, suppresses all output entirely. Reading from /dev/null always immediately returns end-of-file with no data.
Note: command > /dev/null 2>&1 is the standard idiom for "run this and hide all its output".
Example: /dev/null
#!/bin/bash
echo "This will be discarded" > /dev/null
echo "This still prints normally"
ls /no/such/path > /dev/null 2>&1
echo "The error above was silenced. Exit code: $?"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: