Linux Administration
medium
Questão de Linux Administration #019e3987
Enunciado da Questão
Linux Administration
#mtime
#file-command
#redirection
#touch
#sed-inplace
Médio
Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?
A
file /tmp/myfile.txt
Correta
B
echo "Hello" >/tmp/myfile.txt
C
sed -ie "s/1/2/" /tmp/myfile.txt
D
echo -n "Hello" >>/tmp/myfile.txt
E
touch /tmp/myfile.txt
Explicação Oficial / Explicações da Comunidade
The file command is used to determine the type of a file. It reads the file's contents or metadata to classify it (e.g., ASCII text, ELF binary) but does not modify the file in any way. Therefore, it does not update the modify timestamp (mtime) of /tmp/myfile.txt.
How it Works
- Modify timestamp (mtime): Updated when the file's content is changed (written to or truncated).
- Change timestamp (ctime): Updated when file metadata (permissions, ownership) or content changes.
- Access timestamp (atime): Updated when the file is read.
Why the Correct Option is Right
The file /tmp/myfile.txt command only reads the file to determine its type; it does not write to the file or alter its metadata. Thus, mtime remains unchanged.
Why the Incorrect Options are Wrong
echo "Hello" >/tmp/myfile.txt: The>redirection truncates the file and writes new content, updating mtime.sed -ie "s/1/2/" /tmp/myfile.txt: Thesedcommand with-i(in-place) edits the file, modifying its content and updating mtime.echo -n "Hello" >>/tmp/myfile.txt: The>>redirection appends content to the file, changing its content and updating mtime.touch /tmp/myfile.txt: Thetouchcommand explicitly updates the access and modification timestamps to the current time (or a specified time).