博客
关于我
Linux 文件管理 : touch 命令详解
阅读量:281 次
发布时间:2019-03-01

本文共 744 字,大约阅读时间需要 2 分钟。

touch命令是一个强大的文件管理工具,主要有两大功能:一是可以更新已有文件的时间标签,保留文件内容不变;二是可以创建新的空文件。它在日常系统管理中非常有用。

语法

touch命令的基本语法格式为:

touch(选项)(参数)

选项说明

touch命令提供了丰富的选项来满足不同需求:

  • -a--time=atime/--time=access/--time=use:仅更改存取时间,不改变文件内容。
  • -c--no-create:不创建新文件。
  • -d:指定日期时间,更新文件的存取时间、变动时间和创建时间。
  • -f:忽略不予处理,用于解决BSD版本touch指令的兼容性问题。
  • -m--time=modify:仅更改变动时间。
  • -r:参考文件或目录,设置文件时间属性。
  • -t:指定日期时间,更新文件的存取时间、变动时间和创建时间。
  • --help:在线帮助。
  • --version:显示版本信息。

文件时间属性管理

touch命令不仅可以创建文件,还可以修改文件的时间属性,常用的选项有:

  • -a:仅更新存取时间。
  • -m:仅更新变动时间。
  • -d:同时更新存取时间、变动时间和创建时间。

示例说明

以下是touch命令的实际使用示例:

  • 更新文件的存取时间:
  • touch -a aaa.txt
    1. 创建新文件:
    2. touch new_file.txt
      1. 更新文件的变动时间:
      2. touch -m aaa.txt

        注意事项

        • touch命令默认会创建空文件,如果使用-c选项可以避免这一点。
        • -t选项的时间格式为[CC]YY]MMDDhhmm[.ss],例如201907021839表示2019年7月2日20时39分。

        通过合理使用touch命令,可以有效管理文件的时间属性,简化日常系统管理任务。

    转载地址:http://urut.baihongyu.com/

    你可能感兴趣的文章
    Oracle面试题:Oracle中truncate和delete的区别
    查看>>
    ThreadLocal线程内部存储类
    查看>>
    thinkphp 常用SQL执行语句总结
    查看>>
    Oracle:ORA-00911: 无效字符
    查看>>
    Text-to-Image with Diffusion models的巅峰之作:深入解读 DALL·E 2
    查看>>
    TCP基本入门-简单认识一下什么是TCP
    查看>>
    tableviewcell 中使用autolayout自适应高度
    查看>>
    Orcale表被锁
    查看>>
    svn访问报错500
    查看>>
    org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
    查看>>
    org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
    查看>>
    org.apache.poi.hssf.util.Region
    查看>>
    org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
    查看>>
    org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
    查看>>
    org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    查看>>
    org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
    查看>>
    org.tinygroup.serviceprocessor-服务处理器
    查看>>