nerdexam
LPI

101-400 · Question #42

101-400 Question #42: Real Exam Question with Answer & Explanation

The correct answer is C. When the shell establishes the redirection it overwrites the target file before the redirected. See the full explanation below for the reasoning.

Question

When running the command sed -e "s/a/b/" /tmp/file >/tmp/file While /tmp/file contains data, why is /tmp/file empty afterwards?

Options

  • AThe file order is incorrect. The destination file must be mentioned before the command to ensure
  • BThe command sed did not match anything in that file therefore the output is empty.
  • CWhen the shell establishes the redirection it overwrites the target file before the redirected
  • DRedirection for shell commands do not work using the > character. It only works using the |

Community Discussion

No community discussion yet for this question.

Full 101-400 Practice