Display probe's standard output on the terminal.
Discard standard error without displaying or saving it.
Which command is appropriate?
/dev/null discards data written to it. Redirecting only FD 2 there leaves standard output unchanged.
Detailed explanation
probe > /dev/nullIncorrect. It discards standard output and leaves standard error visible.
probe 2> /dev/nullCorrect. Only standard error is sent to /dev/null.
probe < /dev/nullIncorrect. It redirects standard input from /dev/null.
probe 2>&1Incorrect. It merges standard error into standard output rather than discarding it.
Try it yourself
An example you can run in a temporary verification environment.
bash -c 'printf OUT; printf ERR >&2' 2>/dev/nullExpected result
OUTKey points
- Writes to /dev/null are discarded
- 2> targets standard error
- Standard output remains visible
Notes
- Environment: Bash 5.2
- 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.