Linux Foundation Certified System Administrator (LFCS) — Question 78
Which of the following commands will send output from the program myapp to both standard output (stdout) and the file file1.log?
Answer options
- A. cat < myapp | cat > file1.log
- B. myapp 0>&1 | cat > file1.log
- C. myapp | cat > file1.log
- D. myapp | tee file1.log
- E. tee myapp file1.log
Correct answer: D
Explanation
The correct answer is D, as the 'tee' command allows output to be split, sending it simultaneously to the specified file and standard output. Options A, B, and C do not achieve this functionality since they either redirect output to a single channel or do not utilize the 'tee' command. Option E incorrectly attempts to use 'tee' with the program name instead of directing the program's output.