One day a linux base command modified file timestamp touch

Source: Internet
Author: User

Touch Modify Timestamp ( often used to create empty files )

1 , command format

Touch [Options]file ...

2 , command functions

used to modify the file timestamp, access time, modification time, change time, if any parameters are not added by default create an empty file

Linux file time stamp (timestamp) :

Access time: Last accessed ( read ) access

Modified: Write Data modify Change the contents of the file

        Span style= "font-family: ' Times New Roman ', Serif;color: #333333; background: #FFFFFF;" > ( )   Change metadata   properties of changed files

Change time will change automatically, change time will change when the file is accessed, or when the contents of the file are modified

3 , common options

-A : Modify the file access time for the current time, if and - T can be modified to a specified time

- C : Do not create an empty file if the file does not exist

- H : Modification is the timestamp of the linked file rather than the original file

- M : Modify the modification time

- T : modified to the specified time instead of the current time ; [[Cc]yy] MMDDHHMM[.SS]

- R : Timestamp of the current file using the timestamp of the specified file

4 , use instances

1. Create an empty file

command: Touch File

[[Email protected]~]# lsinittab test Test.tar.gz[[email protected]~]# Touch new[[email protected]~]# lsinittab New test Test.tar.gz[[email protected]~]#

2 , modify the file's access time to the current time

command: touch-a File

[[email protected]~]# stat new   file:  ' new '   Size: 0                Blocks:0           IO Block: 4096   regular empty  Filedevice:fd01h/64769d    inode: 527572      links:  1access: (0644/-rw-r--r--)   Uid:  (    0/   root)     Gid:  (    0/   root) access:2016-12-21  10:39:03.988012456 +0800modify:2016-12-21 10:39:03.988012456 +0800change:2016-12-21  10:39:03.988012456 +0800[[email protected]~]# touch -a new [[email  protected]~]# stat new  file:  ' new '   Size: 0                blocks:0          io block: 4096    regular empty filedevice:fd01h/64769d    inode: 527572       links: 1access: (0644/-rw-r--r--)   Uid:  (     0/   root)    Gid:  (    0/    Root) access:2016-12-21 10:40:26.673996182 +0800modify:2016-12-21 10:39:03.988012456 + 0800change:2016-12-21 10:40:26.673996182 +0800[[email protected]~]#

3 , the update file timestamp is the same as another file

command: touch-r File1 File2

[[email protected]~]# stat test  file:  ' Test '   Size: 8                Blocks:8           io block: 4096   regular filedevice: Fd01h/64769d    inode: 527575      links: 1access :(0644/-rw-r--r--)   Uid:  (    0/   root)     gid:  (    0/   root) access: 2016-12-21 10:30:40.233999427  +0800modify:2016-12-20 09:54:30.885994856 +0800change: 2016-12-21 10:30:40.233999427  +0800[[email protected]~]# touch -r test new [[email protected]  ~]# stat test  file:  ' Test '   Size: 8                blocks:8          io  block: 4096   regular filedevice:fd01h/64769d    inode:  527575      links: 1access: (0644/-rw-r--r--)   Uid:  (     0/   root)    Gid:  (    0/    root) access:2016-12-21 10:30:40.233999427 +0800modify:2016-12-20 09:54:30.885994856  +0800change:2016-12-21 10:41:59.919007361 +0800

4 , modify the Access file time stamp to the specified time

command: Touch-at [[CC]YY]MMDDHHMM[.SS] File ...

[[email protected]~]# touch -at 1612121212 new  test[[email protected]~]# stat new  File:  ' new '   size: 0                Blocks:0           io block: 4096   regular empty  fileDevice:fd01h/64769d    Inode: 527572       Links: 1access: (0644/-rw-r--r--)   Uid:  (    0/   root)    Gid:  (    0/   root) access:2016-12-12  12:12:00.000000000 +0800modify:2016-12-21 10:14:42.864999624 +0800change:2016-12-21  10:48:16.047994796 +0800 

Description

- T time Use the specified time value

Time the new value that is the corresponding time stamp for the specified file. The time specified here is a decimal number in the following form :

[[Cc]yy] mmddhhmm[. SS]

CC for the first two digits of the number of years, YY for the latter two digits of the number of years;

If you do not give the CC the value

the Touch The number of years will be set as the year of the current system;

MM is the number of months, DD is the number of days,

hh is the number of hours ( time ) ,

mm is the number of minutes,

SS is the number of seconds.

Stat Displays the timestamp of the file

command: Stat File ...


This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1884631

One day a linux base command modified file timestamp 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.