How to use the Linux touch Command

Source: Internet
Author: User
Tags time and date touch command

The Linux touch command is used to modify the time attribute of a file or directory, including the access time and change time. If the file does not exist, the system creates a new file.

Ls-l can display the time record of the file.

Syntax

Touch [-acfm] [-d <date and time>] [-r <reference file or directory>] [-t <date and time>] [-- help] [-- version] [file or directory…]
  • Parameter description:

  • A. Change the reading time record of the file.

  • M changes the modification time record of the file.

  • C if the target file does not exist, no new file will be created. The same effect as -- no-create.

  • F is not used. It is reserved for compatibility with other unix systems.

  • R uses the time record of the Reference file, which has the same effect as -- file.

  • D. Set the time and date in different formats.

  • T sets the time record of the file. The format is the same as that of the date command.

  • -- No-create does not create a new file.

  • -- Help lists the instruction formats.

  • -- Version: list version information.

Instance

Run the command "touch" to modify the time attribute of file "testfile" to the current system Time. Run the following command:

$ Touch testfile # Modify the time attribute of an object

First, use the ls command to view the attributes of the testfile file, as shown below:

$ Ls-l testfile # view the file's time attribute # The original file's modification time is-rw-r -- 1 hdd 55 testfile

Run the command "touch" to modify the file attributes and view the time attributes of the file again, as shown below:

$ Touch testfile # Modify the file Time attribute to the current system Time $ ls-l testfile # view the file Time attribute # The modified file Time attribute is the current system Time-rw-r -- r -- 1 hdd 55 testfile

When the command "touch" is used, if the specified file does not exist, a new blank file will be created. For example, in the current directory, use this command to create a blank file, and enter the following command:

$ Touch file # Create a new blank file named "file"
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.