zoukankan      html  css  js  c++  java
  • 【Linux】touch命令

    用途

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


    全称

    touch全称即为touch


    参数

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

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

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

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

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

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

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


    案例

    案例一:创建不存在的文件

    [root@bigdata /]# touch 1.txt 2.txt
    [root@bigdata /]# ll *.txt

    总用量 408
    -rw-r--r--.   1 root root      0 8月  15 16:48 1.txt
    -rw-r--r--.   1 root root      0 8月  15 16:48 2.txt


    案例二:更新时间戳

    [root@bigdata /]# ll 1.txt a.txt
    -rw-r--r--. 1 root root   0 8月  15 16:48 1.txt
    -rw-r--r--. 1 root root 680 8月  15 15:01 a.txt

    [root@bigdata /]# touch -r 1.txt a.txt
    [root@bigdata /]# ll 1.txt a.txt

    -rw-r--r--. 1 root root   0 8月  15 16:48 1.txt
    -rw-r--r--. 1 root root 680 8月  15 16:48 a.txt

    案例三:设定文件的时间戳

    [root@bigdata /]# touch -t 200012311830.40 1.txt

    [root@bigdata /]# ll 1.txt
    -rw-r--r--. 1 root root 0 12月 31 2000 1.txt


    案例四:修改文件2.txt的时间为2天前

    [root@bigdata /]# ll 2.txt
    -rw-r--r--. 1 root root 0 8月  15 16:48 2.txt
    [root@bigdata /]# touch -d "2 days ago" 2.txt
    [root@bigdata /]# ll 2.txt

    -rw-r--r--. 1 root root 0 8月  13 16:56 2.txt

  • 相关阅读:
    《秒杀系统架构分析与实战 》
    《豆瓣的基础架构》
    转--《亿级用户下的新浪微博平台架构 》
    转-《蚂蚁金服11.11:支付宝和蚂蚁花呗的技术架构及实践 》
    hdu2029
    hdu2027
    hdu2026(water~~)
    PHP电影小爬虫(2)
    今天来做一个PHP电影小爬虫。
    PHP Simple HTML DOM解析器
  • 原文地址:https://www.cnblogs.com/OliverQin/p/9482588.html
Copyright © 2011-2022 走看看