Linux Foundation Certified System Administrator (LFCS) — Question 98
Which of the following shell redirections will write standard output and standard error output to a file named filename?
Answer options
- A. 2>&1 >filename
- B. >filename 2>&1
- C. 1>&2>filename
- D. >>filename
- E. 1&2>filename
Correct answer: B
Explanation
Option B is correct because it first redirects standard output to the file 'filename' and then redirects standard error to where standard output is currently pointed, which is the file. The other options either redirect the outputs in the wrong order or do not achieve the desired redirection of both outputs to the specified file.