Linux Command Touch

Source: Internet
Author: User

1. Introduction

Change the time of the file or directory, you can update the file access time (Atime, the time when the contents of the file will be changed when the content is read) and the change time (Mtime, the content of the file will change the time)

2. Syntax and parameters

  touch [parameters] [file or directory]

The Touch command creates an empty file when the file does not exist , but does not provide the-C or-H parameter after the touch command

1.-a,--time=atime,--time=access,--time=use

Change only the read time of a file

2.-c,--no-create

Do not create any files

3.-d,--date=string

Use the specified date time instead of the current time, and string is the format of the date.

For example:

[Email protected]:~/c#ls-L A.C-rwxrw-r--1Root root -The -  -: $A.c[email protected]:~/c#Touch--Date="2017-4-1 23:23:23"A.c[email protected]:~/c#ls-L A.C-rwxrw-r--1Root root -Apr1  at: atA.c[email protected]:~/c#ls-L-- Time=CTime A.C-rwxrw-r--1Root root -Sep7  -: AA.c

  Note: By default, LS displays the mtime of the file or directory.  

The mtime of the first file is 8.30,t with touch modified to April 21, 2016, because the touch command changed the properties of the file, so the file's CTime (status time, the state of the file, When a file's properties or permissions are modified, it becomes the latest current time.

4.-F, this parameter is ignored and does not give any processing

5.-m,--time=mtime,--time=modify changes only time (Mtime)

6.-T STAMP uses the specified time in [[CC]YY]]MMDDHHMM[.SS] format instead of the current time

7.-r,--reference=file the time to use this file instead of the current time

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