zoukankan      html  css  js  c++  java
  • touch 创建空文件或改变文件的时间戳属性

    1.命令功能

      touch 改变文件时间属性或创建空文件。

    2.语法格式

    touch  [option]  file

    touch 选项 文件名

    3. 选项参数说明

    参数

    参数说明

    -a

    仅改变文件的访问时间,不改变修改时间

    -m

    改变文件的修改时间

    -r

    把指定文件的日期时间,设定成指定文件的日期时间

    -t time

    使用指定时间值time作为指定文件file相应时间戳的新值

    4.使用范例

    范例1:创建文件,查看时间戳

    [root@localhost cxf]# stat test

      File: `test'

      Size: 0               Blocks: 0          IO Block: 4096   regular empty file

    Device: fd00h/64768d    Inode: 786434      Links: 1

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

    Access: 2018-03-13 16:05:57.226266760 +0800

    Modify: 2018-03-13 16:05:57.226266760 +0800

    Change: 2018-03-13 16:05:57.226266760 +0800

    范例2: touch -a修改test文件的访问时间

    [root@localhost cxf]# touch -a test

    [root@localhost cxf]# stat test

      File: `test'

      Size: 0               Blocks: 0          IO Block: 4096   regular empty file

    Device: fd00h/64768d    Inode: 786434      Links: 1

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

    Access: 2018-03-13 16:07:31.773244835 +0800    #访问时间改变

    Modify: 2018-03-13 16:05:57.226266760 +0800

    Change: 2018-03-13 16:07:31.773244835 +0800   #当访问时间被更新后,状态时间跟着变

    范例3: touch –m修改test文件的修改时间,不改变访问时间

    [root@localhost cxf]# touch -m test

    [root@localhost cxf]# stat test

      File: `test'

      Size: 0               Blocks: 0          IO Block: 4096   regular empty file

    Device: fd00h/64768d    Inode: 786434      Links: 1

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

    Access: 2018-03-13 16:07:31.773244835 +0800

    Modify: 2018-03-13 16:10:32.178280262 +0800  #修改时间变化

    Change: 2018-03-13 16:10:32.178280262 +0800  #修改时间变化,状态也跟着变化

    以上情况说明:只有访问时间或修改时间发生改变,状态时间会同时跟着变化。

    范例4 :touch –d 用法

    [root@localhost home]# touch -d "2017-03-29 16:21:42" test.txt
    [root@localhost home]# stat test.txt
    File: `test.txt'
    Size: 0 Blocks: 0 IO Block: 4096 regular empty file
    Device: fd00h/64768d Inode: 786434 Links: 1
    Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2017-03-29 16:21:42.000000000 +0800
    Modify: 2017-03-29 16:21:42.000000000 +0800
    Change: 2018-03-21 16:45:20.111212090 +0800

  • 相关阅读:
    python打包
    tkinter python(图形开发界面)
    Pyinstaller 打包exe文件 取消dos窗口(黑框框)
    PHP知识点(转载https://www.cnblogs.com/mapsxy/p/9977744.html)
    Java去除字符串中的空格
    开心
    原型链—— javascript
    ajax跨域jsonp —— javascript
    ajax异步 —— javascript
    this —— javascript
  • 原文地址:https://www.cnblogs.com/joechu/p/8617630.html
Copyright © 2011-2022 走看看