Need Help Consider: Is >/dev/null 2>&1 What is happening here? Select the best a
ID: 3903136 • Letter: N
Question
Need Help
Consider: Is >/dev/null 2>&1 What is happening here? Select the best answer The output of the list command is being redirected; first by sending the stdout output to/dev/null (a null device) and secondly by redirecting all stderr output to stdout, thereby "removing" any errors (effectively; no output will be shown, whether the command succeeded/produced a directory listing or whether it failed) The output of the list command is being redirected; first by sending the stdout output to/dev/null (a null device) and secondly by redirecting all stderr output to stdout, thereby "adding" any errors (effectively, all output will be shown) The output of the list command is being streamed; first by sending the stdout output to/dev/null (a null device) and secondly by redirecting all O stdout output to stderr, thereby "removing" any errors (effectively, no output will be shown, whether the command succeeded/produced a directory listing or whether it failed) The output of the list command is being streamed; first by sending the stdout output to/dev/null (a null return device) and secondly by redirecting all stdout output to stderr, thereby "cleaning up" any errors (effectively, all output will be shown)Explanation / Answer
Solution:
Option (C) will be the appropriate answer.
> is for standard output redirection
/dev/null is a generally where data are discarded if any data is sent.
2 is usually used as a file descriptor for Standard Error
> is again used for redirection.
& is for file descriptor
1 is the file descriptor for Standard Out
As >/dev/null 2>&1 is redirect the output of your command to /dev/null. And then redirects standard output to standard error which is again discarded. Finally, no output is shown on the terminal screen.
So, what happening here is the output of “ls” command is being redirected to the /dev/null and the standard error is being redirected to the standard out in order to remove all errors. Thus, no output is displayed on the terminal as data is being already discarded by /dev/null. so it quite confusing whether the operation is successful or not.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.