Linux Command Integration Touch

Source: Internet
Author: User

Describe

Create an empty file or update the file timestamp


Common Command Parameters

-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.


Watch out.

-T time uses the value specified as a new value for the corresponding time stamp of the specified file. The time specified 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, touch will limit the number of years Ccyy to 1969--2068. MM for the number of months, DD for the day will be the number of years Ccyy limited to 1969--2068 within. MM is the number of months, DD is the number of days, HH is the number of hours (several), 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.


Example analysis

1. Create a new file

[[email protected] data]# ls-ltotal 0[[email protected] data]# touch Zyb.txt[[email protected] data]# ls-ltotal 0-rw-r-- R--. 1 root root 0 Apr 19:31 zyb.txt[[email protected] data]#


2. Set the timestamp of the file

[Email protected] data]# ls-ltotal 0-rw-r--r--. 1 root root 0 Apr zyb.txt[[email protected] data]# touch-t 201601201000.00 zyb.txt [[email protected] data]# ls -ltotal 0-rw-r--r--. 1 root root 0 Jan zyb.txt


3. The time stamp of the setting file is the same as other files

[Email protected] data]# ls-ltotal 0-rw-r--r--. 1 root root 0 Apr 19:42 test.txt-rw-r--r--.  1 root root 0 Jan 10:00am zyb.txt[[email protected] data]# touch-r zyb.txt test.txt [[email protected] data]# ls-ltotal 0-rw-r--r--. 1 root root 0 Jan test.txt-rw-r--r--. 1 root root 0 Jan zyb.txt


The references in this article are:

1, http://linux.51yip.com/

2, http://codingstandards.iteye.com/blog/781916

3, http://www.cnblogs.com/peida/archive/2012/10/30/2745714.html

This article is from the "Zhangyb" blog, make sure to keep this source http://zhangyb.blog.51cto.com/11310766/1762402

Linux Command Integration Touch

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.