CompTIA
LX0-103 · Question #19
LX0-103 Question #19: Real Exam Question with Answer & Explanation
The correct answer is A. file /tmp/myfile.txt. The file command reads a file only to detect its type and does not write to it, so it leaves the modify timestamp (mtime) unchanged.
GNU and Unix Commands
Question
Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?
Options
- Afile /tmp/myfile.txt
- Becho "Hello" >/tmp/myfile.txt
- Csed -ie "s/1/2/" /tmp/myfile.txt
- Decho -n "Hello" >>/tmp/myfile.txt
- Etouch /tmp/myfile.txt
Explanation
The file command reads a file only to detect its type and does not write to it, so it leaves the modify timestamp (mtime) unchanged.
Common mistakes.
- B. The > redirection operator truncates and overwrites the file with new content, which updates the modify timestamp.
- C. sed -ie performs an in-place edit, writing the substituted content back to the file and updating mtime.
- D. The >> append operator writes new data to the end of the file, which modifies the file content and updates mtime.
- E. touch explicitly sets the access and modify timestamps of the file, updating mtime by design.
Concept tested. Linux file timestamps and read-only command behavior
Reference. https://man7.org/linux/man-pages/man1/file.1.html
Topics
#timestamp#file command#touch#modify time
Community Discussion
No community discussion yet for this question.