Why we need to use the Touch command

Source: Internet
Author: User
Tags touch command

Why we need to use the Touch command

Since the touch command describes changing timestamps, we might wonder why we need to change the timestamp. This question will cause us to ponder.

However, I would like to have a reason to explain why we need to use it. If you participate in a global open source project, then timestamps can become important.

Compiling the source code file may require a timestamp for the same region. If it is not unified, the program may fail to compile. (PS: The students with obsessive-compulsive disorder also like this command--don't look at the messy time,;>)

In fact, the Linux Touch command is not commonly used, generally used when make can be used to modify the file timestamp.

Make command

Simply put, the make command is like a file-wrapping operation. These goals are usually stored in special files named "Makefile", and the files also contain actions corresponding to the target.

When the make command executes for the first time, it scans the Makefile to find the target and its dependencies. If these dependencies are also targets, continue to establish their dependencies for these dependent scan Makefile, and then compile them.

Once the main dependency is compiled, then the master target is compiled (this is passed in with the Make command).

Now, if you modify a source file, you execute the make command again, and it compiles only the target files associated with that source file, so it saves a lot of time compiling the final executable file.

A. exe typically contains a number of file dependencies. (if file B is generated by file A, file C is generated by File B.) )

Now, if you want to generate a file C again, use the touch command to modify the time of file A; When you execute the Make command, the system discovers that file A is later than file B, and then runs it again.

There are often many-to-many situations in a dependency relationship. If you modify a file on a dependency, you do not want to run all the files for it when you execute the make command, and the system will not know which file you changed.

When you execute the Make command, the system will determine which files need to be run again, based on the timestamp. The same is true of the idea of touch command modification time.

Finally, correct some of the concepts on the touch command modification time.
1. When you touch filename directly, the system automatically updates the file modification time to the current time.
2. If you use touch to modify the file modification time to a specified time,
If the time set is the date of the current month, the display form will not change;
If the established time is not the date of the current month, the year is displayed, and the day is not displayed.

Ps:
When the file is modified, the file modification time changes immediately to the current time, and the natural display format is day of the month.

Ps:

Of course, because the touch command can modify the file access time and modification time, if your boss found some file modification time too early, that you do not have a good job today, you can ...

= =linux New, welcome all kinds of advice.

=0= Sense 谢锋 Brother guidance Maze!

Why we need to use the Touch command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.