LFCS Exam QuestionsBrowse all questions from this exam

LFCS Exam - Question 71


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 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

2 comments
Sign in to comment
StribOption: B
Jun 16, 2023

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.

9866666Option: B
Jun 25, 2024

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