101-400 Exam QuestionsBrowse all questions from this exam

101-400 Exam - Question 65


Which of the following shell redirections will write standard output and standard error output to a file named filename?

Show Answer
Correct Answer: B

To write standard output and standard error output to a file named filename, the correct redirection syntax is: `>filename 2>&1`. In this syntax, `>filename` redirects the standard output to the file `filename`, and `2>&1` redirects the standard error (file descriptor 2) to the same location as the standard output (file descriptor 1). This ensures that both standard output and standard error are written to the file `filename`.

Discussion

1 comment
Sign in to comment
DuboisNicolasDuclairOption: B
Oct 21, 2023

The shell redirection that will write standard output and standard error output to a file named `filename` is: B. `>filename 2>&1` In this redirection, `>filename` redirects standard output to the file `filename`, and `2>&1` redirects standard error (file descriptor 2) to the same location as standard output (file descriptor 1), which is the file `filename`. This way, both standard output and standard error are written to the same file.