zoukankan      html  css  js  c++  java
  • Linux命令(4):touch

    功能说明:

           touch命令参数可创建新文件以及更改文档或目录的日期时间,包括存取时间和更改时间。 

    命令格式:

            touch [选项]... 文件...

    命令参数:   

    -a   或--time=atime或--time=access或--time=use  只更改存取时间。

    -c   或--no-create  不建立任何文档。

    -d  使用指定的日期时间,而非现在的时间。

    -f  此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。

    -m   或--time=mtime或--time=modify  只更改变动时间。

    -r  把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。

    -t  使用指定的日期时间,而非现在的时间。

    命令案例:

    案例1、创建一个新文件

    [root@oldboy miao]# touch a.txt b.log
    [root@oldboy miao]# ll
    total 0
    -rw-r--r-- 1 root root 0 Aug 7 17:01 a.txt
    -rw-r--r-- 1 root root 0 Aug 7 17:01 b.log
    [root@oldboy miao]#

    案例2、更新a.txt的时间和b.log时间戳相同

    [root@oldboy miao]# ll
    total 0
    -rw-r--r-- 1 root root 0 Aug 7 17:06 a.log
    -rw-r--r-- 1 root root 0 Aug 7 17:01 a.txt
    -rw-r--r-- 1 root root 0 Aug 7 17:01 b.log
    [root@oldboy miao]# touch -r a.txt a.log
    [root@oldboy miao]# ll
    total 0
    -rw-r--r-- 1 root root 0 Aug 7 17:01 a.log
    -rw-r--r-- 1 root root 0 Aug 7 17:01 a.txt
    -rw-r--r-- 1 root root 0 Aug 7 17:01 b.log
    [root@oldboy miao]#

    案例3、设定文件的时间戳

    [root@oldboy miao]# touch -t 201408010000.00 a.log
    [root@oldboy miao]# ll
    total 0
    -rw-r--r-- 1 root root 0 Aug 1 00:00 a.log
    -rw-r--r-- 1 root root 0 Aug 7 17:01 a.txt
    -rw-r--r-- 1 root root 0 Aug 7 17:01 b.log
    [root@oldboy miao]#

    说明:此处的 time规定为如下形式的十进制数:       [[CC]YY]MMDDhhmm[.SS]     由于系统的限制,早于1970年1月1日的时间是错误的。

     

     

  • 相关阅读:
    vuejs中使用echart图表
    锚点链接
    如何动态修改网页的标题(title)?
    如何为图片添加热点链接?(map + area)
    cookie
    如何为你的网站添加标志性的图标(头像)呢?
    图片拖拽上传至服务器
    js定时器之setTimeout的使用
    input[type=file]中使用ajaxSubmit来图片上传
    input[type=file]样式更改以及图片上传预览
  • 原文地址:https://www.cnblogs.com/miaokm/p/3897705.html
Copyright © 2011-2022 走看看