Linux commands (4): Touch

Source: Internet
Author: User
Tags touch command

Function Description:

The Touch command parameter creates a new file and changes the date and time of the document or directory, including access time and change time.

Command format:

touch [Options] ... File...

Command parameters:

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

-C or--no-create does not establish any documents.

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

Command case:

Case 1, create a new file

[email protected] miao]# Touch a.txt B.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#

Case 2, Update a.txt time and B.log timestamp are the same

[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:06 A.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]# touch-r a.txt a.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:01 A.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#

Case 3, set the timestamp of the file

[Email protected] miao]# touch-t 201408010000.00 a.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 1 00:00 a.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#

Description: The time specified here is a decimal number in the following form: [[cc]yy]mmddhhmm[]. SS] Due to system limitations, the time earlier than January 1, 1970 was wrong.

Related Article

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.