PrepAway - Latest Free Exam Questions & Answers

Which of the following commands will you use to accomplish the task?

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?

PrepAway - Latest Free Exam Questions & Answers

A.
wc -c file1.txt >>error.txt

B.
wc -c file1.txt 1>error.txt

C.
wc -c file1.txt 2>error.txt

D.
wc -c file1.txt >error.txt

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 options D and B 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 whole output.
Answer option 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.


Leave a Reply