Common Linux commands (8) and common linux commands

Source: Internet
Author: User
Tags touch command

Common Linux commands (8) and common linux commands

Linux touch commands are not commonly used. They are generally used to modify the file timestamp or create a new file that does not exist.

1. Command Format:

Touch [Option] File


2. command parameters:

-A only changes the access time.

-C does not create any documents.

-D uses the specified date and time instead of the current time.

-F this parameter will not be processed. It is only responsible for solving the compatibility problem of the BSD touch command.

-M: only the change time is changed.

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

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


3. command functions:

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


4. Command instance:

Instance 1:Create a non-existent file

Command: touch log22.log log33.log

Creates two files: log22.log and log33.log.


Command: touch-c log44.log

NOTE: If log44.log does not exist, no file is created.


Example 2:Update Timestamp

Command: touch-r log22.log log33.log

Note: The timestamp of log33.log is updated to be the same as log22.log.


Example 3:Set the file Timestamp

Command: touch-t 201211142234.50 log22.log

Note:-t time uses the specified time value time as the new value of the corresponding time stamp of the specified file. the time here is defined as the following decimal number: [[CC] YY] MMDDhhmm [. SS] Here, CC is the first two in the number of years, that is, the number of centuries. YY is the last two in the number of years, that is, the number of years in a century. if the value of C is not given, touch limits the number of years CCYY to within 1969--2068. MM indicates the number of months. DD indicates the number of years CCYY is limited. MM indicates the number of months, DD indicates the number of days, hh indicates the number of hours (when), mm indicates the number of minutes, and SS indicates the number of seconds. the second is set to 0--61, which can process leap seconds. the time composed of these numbers is a time zone specified by the Environment Variable TZ. due to system restrictions, the time earlier than January 1, January 1, 1970 is incorrect.





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.