Linux under touch command to modify file timestamp

Source: Internet
Author: User
Tags touch command

Linux of the Touch command to modify the file timestamp, or create a new file that does not exist .

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/3E/wKiom1c8AQbyRcOfAAA4lWtVNn4553.png "title=" Qq20160518110554.png "style=" Float:left, "alt=" Wkiom1c8aqbyrcofaaa4lwtvnn4553.png "/> , access, modify, The change is the time of the visit, the time of the modification, and the time of the file, which is the timestamp.

1 . command format:

Touch [ options] ... File name ...

2 . Command parameters:

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

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

- D use the specified date time instead of the current time.

- F This parameter ignores non-processing and is responsible only for compatibility issues with BSD version touch directives.

- M or--time=mtime or--time=modify only change the change time.

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

- T use the specified date time instead of the current time.

3 . Command function:

Touch the command parameter can change the date time of the document or directory, including access time and change time.  

4 . Examples of use:

Instance one: Create a file that does not exist

Command:

Touch Test1.txt test2.txt

Output:

[[email protected] test] # Touch test1.txt test2.txt

[[email protected] test] # ll

-rw-r--r--. 1root Root 0 11:11 test1.txt

-rw-r--r--. 1 root root 0 may 11:11 Test2.txt

if Test3.txt does not exist, the file is not created

[[email protected] test] # touch-c test3.txt

[[email protected] test] # ll

-rw-r--r--. 1root Root 0 11:11 test1.txt

-rw-r--r--. 1 root root 0 may 11:11 Test2.txt

Example two: Update Test.txt the time and Test2.txt same time stamp

Command:

Touch-r Test.txt Test2.txt

Output:

[email protected] test]# Touch test.txt

[Email protected] test]# touch-r test.txt test2.txt

[email protected] test]# LL

Total 0

-rw-r--r--. 1 root root 0 may 11:11 Test1.txt

-rw-r--r--. 1 root root 0 may 11:22 Test2.txt

-rw-r--r--. 1 root root 0 may 11:22 test.txt

Example three: Setting the timestamp of a file

Command:

Touch-t 201605171210.20 Test.txt

Output:

[[email protected] test] # ll

-rw-r--r--. 1root Root 0 11:11 test1.txt

-rw-r--r--. 1 root root 0 may 11:22 Test2.txt

-rw-r--r--. 1 root root 0 may 11:22 test.txt

[[email protected] test] # touch-t 201605171210.20 test.txt

[[email protected] test] # ll

-rw-r--r--. 1 Rootroot 0 11:11 test1.txt

-rw-r--r--. 1 root root 0 may 11:22 Test2.txt

-rw-r--r--. 1 root root 0 may 12:10 test.txt

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/3E/wKiom1c8AGyRIBV8AABFOXJqlUM509.png "title=" 111. PNG "style=" float:left; "alt=" Wkiom1c8agyribv8aabfoxjqlum509.png "/>

Description

- T time uses the time value specified as the 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.


This article is from the "Looger" blog, make sure to keep this source http://lsbhjshyn.blog.51cto.com/1336660/1774703

Linux under touch command to modify file timestamp

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.