The touch of Linux common commands

Source: Internet
Author: User
Tags syslog

Touch: Update file time or create a blank file


1. Command format

Touch [options] File

2. Command function

The intent is to update the timestamp of the file, which is now used to create a blank file.

3. Command parameters

-A: Change access time only

-M: Change only the modified time

-C: Do not create any files

-T: Use the specified date and time instead of the current time

4. Command instances

Example 1: Create a blank file that does not exist

[email protected] ~]# Touch file1

[[email protected] ~]# ls

AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog

Example 2: Changing the access time

[Email protected] ~]# stat file1

File: ' File1 '

size:0 blocks:0 IO block:4096 Regular empty file

device:803h/2051dinode:2709265 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2014-12-21 17:02:49.000000000 +0800

Modify:2014-12-21 17:02:49.000000000 +0800

Change:2014-12-21 17:02:49.000000000 +0800

[Email protected] ~]# touch-a file1

[Email protected] ~]# stat file1

File: ' File1 '

size:0 blocks:0 IO block:4096 Regular empty file

device:803h/2051dinode:2709265 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2014-12-21 17:05:37.000000000 +0800

Modify:2014-12-21 17:02:49.000000000 +0800

Change:2014-12-21 17:05:37.000000000 +0800

Example 3: Change the modification time

[Email protected] ~]# stat file1

File: ' File1 '

size:0 blocks:0 IO block:4096 Regular empty file

device:803h/2051dinode:2709265 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2014-12-21 17:05:37.000000000 +0800

Modify:2014-12-21 17:02:49.000000000 +0800

Change:2014-12-21 17:05:37.000000000 +0800

[Email protected] ~]# touch-m file1

[Email protected] ~]# stat file1

File: ' File1 '

size:0 blocks:0 IO block:4096 Regular empty file

device:803h/2051dinode:2709265 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2014-12-21 17:05:37.000000000 +0800

Modify:2014-12-21 17:07:48.000000000 +0800

Change:2014-12-21 17:07:48.000000000 +0800

Example 4: Do not create any files

[[email protected] ~]# ls

AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog

[Email protected] ~]# touch-c file2

[[email protected] ~]# ls

AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog

Example 5: Using the specified time

[Email protected] ~]# touch-t 201412211712.30 file2

[Email protected] ~]# stat file2

File: ' File2 '

size:0 blocks:0 IO block:4096 Regular empty file

device:803h/2051dinode:2709266 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2014-12-21 17:12:30.000000000 +0800

Modify:2014-12-21 17:12:30.000000000 +0800

Change:2014-12-21 17:13:20.000000000 +0800









This article is from the "cold-blooded Killer" blog, please be sure to keep this source http://deathkiller.blog.51cto.com/9130248/1592314

The touch of Linux common commands

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.