Display probe standard output on the terminal.
Discard permission and other standard-error messages without displaying or saving them.
Which form is appropriate?
2>/dev/null sends only file descriptor 2 to the null device while leaving standard output unchanged.
Detailed explanation
probe 2> /dev/nullCorrect. stderr is discarded and stdout still reaches the terminal.
Correct. stderr is discarded and stdout still reaches the terminal.
probe > /dev/nullIncorrect. This discards stdout and leaves stderr visible.
Incorrect. This discards stdout and leaves stderr visible.
probe > /dev/null 2>&1Incorrect. Both stdout and stderr are discarded.
Incorrect. Both stdout and stderr are discarded.
probe < /dev/nullIncorrect. This changes standard input, not the destination of stderr.
Incorrect. This changes standard input, not the destination of stderr.
Try it yourself
An example you can run in a temporary verification environment.
sh -c 'echo visible; echo hidden >&2' 2>/dev/nullExpected result
visibleKey points
- /dev/null is a discard sink
- 2> targets stderr
- stdout remains connected
Notes
- Environment: Linux / POSIX shell / /dev/null
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.