修改系统文件触摸屏反了
Every file on your computer has a timestamp, which contains the access and modification time for a file, but did you know that you can change that timestamp? Here’s how to do it.
您计算机上的每个文件都有一个时间戳,其中包含文件的访问和修改时间,但是您知道可以更改该时间戳吗? 这是操作方法。
使用触摸命令 (Using the Touch Command)
The “touch” command is available pretty much anywhere that you can get the Bash shell, which includes Linux or Windows with Cygwin installed. Here’s the options for the command:
在任何可以获得Bash shell的地方,几乎都可以使用“ touch”命令,包括安装了CygwinLinux或Windows。 这是命令的选项:
If you want to check the file timestamp, you can do so with this command:
如果要检查文件时间戳,可以使用以下命令:
stat file
统计文件
Obviously you should make sure to replace “file” with your file’s name.
显然,您应该确保将“ file”替换为文件名。
-a和-m选项 (-a and -m options)
These two options update the access and modification time respectively. Using them should be no problem at all. Here is the syntax:
这两个选项分别更新访问和修改时间。 使用它们应该完全没有问题。 语法如下:
touch –a file
触摸–文件
This will update “file”s access time to the current date and time. You can replace the (-a) options with (-m) to do the same but for the modification time. If the file doesn’t exist, an empty file with the same name will be created in the current directory.
这会将“文件”的访问时间更新为当前日期和时间。 您可以将(-a)选项替换为(-m)以进行相同的操作,但要进行修改。 如果该文件不存在,则将在当前目录中创建一个具有相同名称的空文件。
-c选项 (-c option)
If you use this option, touch won’t do anything at all if the file specified doesn’t exist. Look:
如果使用此选项,则在指定的文件不存在的情况下,touch根本不会执行任何操作。 看:
touch –c omar
触摸–c omar
In the above example touch will do nothing as “omar”, the file not the person, doesn’t exist.
在上面的示例中,touch不会执行任何操作,因为“ omar”(不是人的文件)不存在。
-r选项 (-r option)
This option might come in handy if you want to copy a timestamp from a file to another file. Like so:
如果要将时间戳从文件复制到另一个文件,此选项可能会派上用场。 像这样:
touch –r file1 file2
触摸–r file1 file2
Where “file1” is the reference file and “file2” is the file that will be updated. If you want to copy the timestamp to more than one file you can provide them all in the command as well and they will be created simultaneously.
其中“ file1”是参考文件,“ file2”是将要更新的文件。 如果要将时间戳复制到多个文件中,则也可以在命令中同时提供它们,并且它们将同时创建。
touch –r file1 file2 file3 file4
触摸–r file1 file2 file3 file4
-d和–t选项 (-d and –t options)
Both (-d) and (-t) options do the same thing, which is setting the same arbitrary timestamp for access and modification times. The difference is that (-d) uses free format human readable date, this means that you can use “Sun, 29 Feb 2004 16:21:42” or “2004-02-29 16:21:42” or even “next Thursday”. This option is complex to fully describe it here. On the other hand (-t) uses a simple stamp that you are confined to use. The stamp is [[CC]YY]MMDDhhmm[.ss]. [CC] is for century and you may ignore it and ignore the seconds as well. If you ignore [CC] the command will substitute it depending on what you enter as year. If you specify the year with only two digits, then CC is 20 for years in the range (0~68) and 19 for years in (69~99).
(-d)和(-t)选项都具有相同的作用,即为访问和修改时间设置相同的任意时间戳。 区别在于(-d)使用自由格式的人类可读日期,这意味着您可以使用“ Sun,29 Feb 2004 16:21:42”或“ 2004-02-29 16:21:42”甚至“ next”星期四”。 此选项很复杂,无法在此处完整描述。 另一方面(-t)使用一个仅限您使用的简单图章。 标记是[[CC] YY] MMDDhhmm [.ss]。 [CC]用于世纪,您可以忽略它,也可以忽略秒。 如果忽略[CC],该命令将根据您输入的年份替换它。 如果仅用两位数字指定年份,则对于(0〜68)范围内的年份,CC为20,对于(69〜99)范围内的年份,CC为19。
touch –t 3404152240 file
触摸–t 3404152240文件
touch –t 8804152240 file
触摸–t 8804152240文件
In the first command the file timestamps will be set to: 15th April 2034 10:40 PM. While the second command will set it to: 15th April 1988 which is in a different century. If no year is specified it will be set to the current year. Example:
在第一个命令中,文件时间戳记将设置为:2034年4月15日晚上10:40。 第二个命令将其设置为:1988年4月15日,这是一个不同的世纪。 如果未指定年份,则将其设置为当前年份。 例:
touch –t 04152240 file
触摸–t 04152240文件
This will set the timestamp to 15th April 2011 10:40 PM because it is 2011 by the time of writing this article.
这将把时间戳设置为2011年4月15 日 10:40 PM,因为在撰写本文时是2011年。
组合选项以设置任意的个人访问和修改时间 (Combining Options to Set Arbitrary Individual Access and Modification Times)
The (-a) and (-m) options only updates the timestamps to current time and the (-d) and (t) options sets both access and modification timestamps to the same time. Assume you only only want to set the access time to the 5th of June 2016 at 5:30 PM, How would you do that? Well, you’ll use (-a) and (-t) to both set an arbitrary time and apply it only for the access timestamp. Example:
(-a)和(-m)选项仅将时间戳更新为当前时间,而(-d)和(t)选项将访问和修改时间戳设置为同一时间。 假设你只有唯一想设置的访问时间5 日 2016六下午5:30,你会怎么做? 好了,您将使用(-a)和(-t)来设置一个任意时间,并将其仅应用于访问时间戳。 例:
touch –at 1606051730 file
触摸–at 1606051730文件
or
要么
touch –a -t 1606051730 file
触摸–a -t 1606051730文件
And if you want to do the same for the modification time just substitute (-at) with (-mt). It’s easy.
如果要在修改时间执行相同操作,只需将(-at)替换为(-mt)。 这简单。
创建空文件 (Creating Empty Files)
The second and most famous usage of the touch command is creating empty files. This might sound stupid, why would anyone sensibly overload his computer with empty nonsense files but it really comes to use when, for example, you are working on a project and want to keep track of progress with dates and times. So you’ll have a folder with the project’s name and use touch to create empty files with the events as names of file. In other words, you can use it to create logs. Example:
touch命令的第二个最著名的用法是创建空文件。 这听起来可能很愚蠢,为什么有人会用空的废话文件明智地使计算机超载,但在例如正在处理项目并希望跟踪日期和时间的进度时,它才真正有用。 因此,您将拥有一个包含项目名称的文件夹,并使用touch创建以事件为文件名的空文件。 换句话说,您可以使用它来创建日志。 例:
touch ~/desktop/project/stage1_completed
触摸〜/ desktop / project / stage1_completed
Now you have a file signifying the completion of stage 1 of the project at the time of creating this file and you can see this time by issuing the command:
现在,您有一个文件,表示在创建此文件时项目第一阶段的完成,并且可以通过发出以下命令来查看该时间:
stat ~/desktop/project/stage1_completed
stat〜/ desktop / project / stage1_completed
You can find touch useful in different ways depending on what you do. If you know more good uses for touch then share it in the comments or read more about the touch command by visiting its man page online or in a terminal by issuing the command “man touch”.
您可以根据自己的工作以不同的方式找到有用的触摸。 如果您知道触摸的更多好处,请在注释中分享它,或者通过在线访问其手册页或在终端中发出“ man touch”命令来阅读有关touch命令的更多信息。
翻译自: https://www.howtogeek.com/74667/how-to-use-touch-to-create-empty-files-and-modify-timestamps/
修改系统文件触摸屏反了