Linux commands (6)--touch, stat command

Source: Internet
Author: User
Tags touch command

Touch command: Touch-change file timestamps

function

Touch command to create an empty file, or to manage file timestamps (you need to specify options)

Syntax

touch [option] filename does not add the option to create a file directly

"File timestamp type"

Access time is changed after reading a file//such as using a command such as cat. Modify time modified to change the file contents (data) Change time changed


Options

Change Timestamp option-a means that the access time for the file is specified as the current time-m means that the file's change time is specified as the current time-t specifies the timestamp of the file as any time mmddhhmm[cc| Yy].ss-b file is not created if the file does not exist


"Instance 1" Touch Create file

[[email protected] tmp]# Touch file1 file2 file3 file4[[email protected] tmp]# lsfile1 file2 file3 file4[[email Protect Ed] tmp]# Lltotal 0-rw-r--r--. 1 root root 0 Apr 6 10:57 file1-rw-r--r--. 1 root root 0 Apr 6 10:57 file2-rw-r--r--. 1 root root 0 Apr 6 10:57 file3-rw-r--r--. 1 root root 0 Apr 6 10:57 file4[[email protected] tmp]#

"Instance 2" stat command

View file properties: Displays file size, file type, inode number, permissions, group owner, and other related information [[email protected] tmp]# stat file1 file: ' file1 ' size:0 Blocks:   0 IO block:4096 Regular empty filedevice:801h/2049d inode:2228226 links:1access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root) access:2016-04-06 10:57:56.684007129 +0800modify:2016-04-06 11:01:39.7439 97818 +0800change:2016-04-06 11:01:39.743997818 +0800


"Instance 3" view file timestamp, and change

[[email protected] tmp]# stat file1  file:  ' File1 '   Size: 0                Blocks: 0           IO Block: 4096   regular  empty filedevice: 801h/2049d      inode: 2228226      Links: 1Access:  (0644/-rw-r--r--)   Uid:  (    0/     root)    Gid:  (    0/     Root) access: 2016-04-06 10:57:56.684007129 +0800modify: 2016-04-06 10:57:56.684007129  +0800    //change the file change time Change: 2016-04-06 10:57:56.684007129 +0800[[email  protected] tmp]# touch -m 040820161759 file1[[email protected] tmp]#  stat file1  file:  ' File1 '   Size: 0                Blocks: 0           io block: 4096   regular empty filedevice: 801h/2049d       Inode: 2228226     Links: 1Access:  (0644/- rw-r--r--)   Uid:  (    0/    root)    gid:   (    0/    root) access: 2016-04-06 10:57:56.684007129  +0800modify: 2016-04-06 11:01:39.743997818 +0800   //has changed my time there's a problem, Time format is different change: 2016-04-06 11:01:39.743997818 +0800

This article is from the "Perthon" blog, make sure to keep this source http://perthon.blog.51cto.com/10484057/1761860

Linux commands (6)--touch, stat command

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.