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:

Jaclyn
27 days ago
Ah, the age-old question of why my output file is mysteriously empty. I bet the answer is hidden somewhere in the dark corners of the shell's arcane ways. Time to channel my inner shell wizard and figure this one out.
upvoted 0 times
Ligia
8 days ago
A) The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
upvoted 0 times
...
...
Truman
28 days ago
Hold up, redirection doesn't work with the '>' character? Seriously? I guess I've been using the wrong tool for the job all this time. Time to brush up on my shell command-fu.
upvoted 0 times
...
Clorinda
1 months 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
Kizzy
2 days ago
I see, so the shell takes care of the redirection before the command even starts. Good to know for future reference.
upvoted 0 times
...
Providencia
3 days ago
Yeah, that's right. The shell is quick to overwrite the target file before the command executes. It's important to keep that in mind when using redirection.
upvoted 0 times
...
Gail
4 days 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
2 months ago
Hmm, that makes sense too. Maybe we should review how sed works before the exam.
upvoted 0 times
...
Amber
2 months 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
Norah
26 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
...
Karima
1 months ago
A) The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
upvoted 0 times
...
...
Julieta
2 months ago
I disagree, I believe the answer is B. The sed command did not match anything in the file.
upvoted 0 times
...
Lewis
2 months 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 months 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
1 months ago
B) The command sed did not match anything in that file therefore the output is empty.
upvoted 0 times
...
Josefa
1 months ago
A) The file order is incorrect. The destination file must be mentioned before the command to ensure redirection.
upvoted 0 times
...
...
Alesia
2 months ago
I think the answer is C. The shell overwrites the target file before the command starts.
upvoted 0 times
...

Save Cancel