Exam LFCS All QuestionsBrowse all questions from this exam
Question 71

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

    Correct Answer: B

    To write both standard output (stdout) and standard error (stderr) to a file named 'filename,' the redirection syntax needs to correctly combine both streams. The correct syntax for this is '>filename 2>&1'. This command redirects stdout to the file 'filename' and then redirects stderr (file descriptor 2) to where stdout (file descriptor 1) is currently pointing, which is the file 'filename'. This ensures that both types of output go to the same file.

Discussion
9866666Option: B

The correct answer is B. >filename 2>&1

StribOption: B

The correct option is: B. Explanation: To write both standard output (stdout) and standard error output (stderr) to a file named "filename," you need to redirect both streams appropriately. By combining these redirections, both stdout and stderr will be written to the file named "filename." Any errors or regular output generated by the command will be captured in the same file.