nerdexam
GIAC

GSNA · Question #325

You run the wc -c file1.txt command. If this command displays any error message, you want to store the error message in the error.txt file. Which of the following commands will you use to accomplish…

The correct answer is C. wc -c file1.txt 2>error.txt. According to the scenario, you will use the wc -c file1.txt 2>error.txt command to accomplish the task. The 2> operator is an error redirector, which, while running a command, redirects the error (if it exists) on the specified file. Answer: B, D are incorrect. The > or 1>…

Linux/Unix System Auditing

Question

You run the wc -c file1.txt command. If this command displays any error message, you want to store the error message in the error.txt file. Which of the following commands will you use to accomplish the task?

Options

  • Awc -c file1.txt >>error.txt
  • Bwc -c file1.txt 1>error.txt
  • Cwc -c file1.txt 2>error.txt
  • Dwc -c file1.txt >error.txt

How the community answered

(30 responses)
  • A
    10% (3)
  • B
    3% (1)
  • C
    70% (21)
  • D
    17% (5)

Explanation

According to the scenario, you will use the wc -c file1.txt 2>error.txt command to accomplish the task. The 2> operator is an error redirector, which, while running a command, redirects the error (if it exists) on the specified file. Answer: B, D are incorrect. The > or 1> redirector can be used to redirect the output of the wc -c file1.txt file to the error.txt file; however, you want to write the errors in the error.txt file, not the Answer: A is incorrect. The >> operator will redirect the output of the command in the same manner as the > or 1> operator. Although the >> operator will not overwrite the error.txt file, it will append the error.txt file.

Topics

#stderr redirection#Linux shell#wc command#file redirection

Community Discussion

No community discussion yet for this question.

Full GSNA Practice