Update the file, but do not change the file modification date. It can be done?

On Linux, you can change the contents of a file, but keep the same modification date for this file? If so, how? Thanks.

+4
source share
3 answers

Get what is the modification date of your file. Change the contents of your files, and then you can change the date of the change with the touch command. for instance

 touch -m -t 09082000 file to change the modification time to 8 sep, 20:00. 

You can also change the modification date to the past, for 10/15/1998 12:30 the command will be something like this:

 touch -m -t 19981015123000 file 
+8
source

Another possibility could be a symbolic link?

if you have alink->a.txt , you are changing the contents of the a.txt file, alink modification will not be updated recently.

+1
source

You can remember the date of change before changing the content; After changing the content, you can change the date to the original value. This can be done on Linux from the command line. For instance:

touch -t 09082000 file change the modification time to 8 sep, 20:00. More details can be found here.

+1
source

Source: https://habr.com/ru/post/1380773/


All Articles