One Linux command per day (--touch) command

Source: Internet
Author: User
Tags touch command

Linux touch commands are not commonly used, and are generally used when using make, to modify file timestamps, or to create a new file that does not exist.

1. Command format:

Touch [option] Documents ...

2. Command parameters:

-A or--time=atime or--time=access or--time=use only change access time

-C or--no-create do not create any documents

-D uses the specified datetime instead of the current time

-F This parameter ignores non-handling and is only responsible for compatibility issues with BSD version touch Directives--------Rare to see a-F eat flat, never ignore others, and eventually be ignored. ^^

-M or--time=mtime or--time=modify only change the change time. -------Tell the truth, I don't know what the use of this feature is, if you know who you are, tell me.

-R Sets the date and time of the specified document or directory to the same date and time as the reference document or directory.

-T uses the specified date time instead of the current time

3. Command function:

Touch command parameter to change the date and time of a document or directory, including access time and change time

4. Usage examples:

Instance one: Create a file that does not exist

Command:

Touch 001.log 002.log creates two 001 and 002 log files at a time

Touch-c 003.log If the 003 does not exist, the file is not created. If 003 is present, the time will be updated to prove that it has been moved by humans. -----What is the use of this order? I mean, I'm confused.

Example two: Update 001.log time and 002.log timestamp same

Command:

Touch-r 001.log 002.log

Example three: Setting the timestamp of a file

Command:

Touch-t 000001010000 001.log time set at 000001010000 can not all 0 or negative, no wonder BC people do not surf the Internet.

-T time uses the value specified as the new value for the relative timestamp of the specified file. Here is a decimal number in the following form:

[[Cc]yy] mmddhhmm[. SS]

Here, CC is the first two digits of the number of years, that is, "century"; yy is the last two digits of the number of years, that is, the number of years in a century. If the value of CC is not given, then touch will limit the number of years Ccyy to 1969--2068, MM is the number of months, DD is the number of days, HH is the number of hours, MM is the number of minutes, SS is the number of seconds. The set range of seconds here is 0-61, which can handle leap seconds. These numbers consist of a time in the time zone specified by the environment variable TZ. Due to system limitations, the time earlier than January 1, 1970 was wrong. I used the system is modified, all will appear 000001010000

One Linux command per day (--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.