谷动谷力

标题: Linux创建文件修改目录的时间属性touch命令 [打印本页]

作者: sunsili    时间: 2021-8-14 16:55
标题: Linux创建文件修改目录的时间属性touch命令
本帖最后由 sunsili 于 2021-8-14 17:18 编辑

touch命令主要有两个功能:

不会用的命令
首先
  1. touch --help
复制代码


常见参数详解:
-a  change only the access time
-c, --no-create
       do not create any files
-d, --date=STRING
       parse STRING and use it instead of current time
-f     (ignored)
-h, --no-dereference
       affect  each symbolic link instead of any referenced file (useful only       on systems that can change the timestamps of a symlink)
-m     change only the modification time
-r, --reference=FILE
       use this file's times instead of current time
-t STAMP
      use [[CC]YY]MMDDhhmm[.ss] instead of current time
--time=WORD
      change the specified time: WORD is access, atime, or  use:  equivalent
      to -a WORD is modify or mtime: equivalent to -m

参数说明二、实战
#创建一个不存在的空文件,如果存在无影响

  1. #创建一个不存在的空文件,如果存在无影响
  2. touch t1.txt
  3. # 改变文件的时间戳
  4. touch -t 202010091130 t1.txt
  5. ll
  6. -rw-r--r--. 1 root root 4 Oct  9 11:30 t1.txt
复制代码







欢迎光临 谷动谷力 (http://bbs.sunsili.com/) Powered by Discuz! X3.2