Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Linux Foundation Exam LFCS Topic 2 Question 53 Discussion

Actual exam question for Linux Foundation's LFCS exam
Question #: 53
Topic #: 2
[All LFCS Questions]

When running the command

sed -e "s/a/b/" /tmp/file >/tmp/file

While /tmp/file contains data, why is /tmp/file empty afterwards?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Clorinda
2 hours ago
I'm going with option C on this one. The shell is like a ninja, silently overwriting the target file before the command even has a chance to do its thing. Sneaky, but that's how it works.
upvoted 0 times
...
Alesia
14 days ago
Hmm, that makes sense too. Maybe we should review how sed works before the exam.
upvoted 0 times
...
Amber
14 days ago
Hmm, let's see... the file order is definitely not the issue here. And the sed command seems to be working fine, so it's not that either. Aha, I bet it's that sneaky overwrite that happens before the redirection kicks in! Gotta love those shell quirks.
upvoted 0 times
...
Julieta
16 days ago
I disagree, I believe the answer is B. The sed command did not match anything in the file.
upvoted 0 times
...
Lewis
17 days ago
Whoa, talk about a classic shell command conundrum! I bet the folks who write these certification exams just love tripping us up with little gotchas like this.
upvoted 0 times
Janet
1 days ago
C) When the shell establishes the redirection it overwrites the target file before the redirected command starts and opens it for reading.
upvoted 0 times
...
Eliz
2 days ago
B) The command sed did not match anything in that file therefore the output is empty.
upvoted 0 times
...
Josefa
6 days ago
A) The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
upvoted 0 times
...
...
Alesia
26 days ago
I think the answer is C. The shell overwrites the target file before the command starts.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77