1. 同时修改文件的修改时间和访问时间
touch -d "2010-05-31 08:10:30" test.doc

2. 只修改文件的修改时间
touch -m -d "2010-05-31 08:10:30" test.doc

3. 只修改文件的访问时间
touch -a -d "2010-05-31 08:10:30" test.doc

4.touch -d 和 date -s 的用法相同。如果没有指定日期,默认为系统日期
touch -d 18:03 file
touch -d "18:03" file
touch -d "6:03pm" file
如果没有指定时间,默认为 00:00:00
touch -d 20000506 file
touch -d "05/06/2000" file
touch -d "20000506" filetouch -d "6:03pm 05/06/2000" file
touch -d "20000506 18:03" file
touch -d "20000506 18:03:00" file

Linux 下查看文件时,ls –l 缺省是不显示秒的:

$ ls -l
total 0
-rw-r--r-- 1 gps gps 0 2012-06-12 16:21 README.txt
-rw-r--r-- 1 gps gps 0 2012-06-12 16:21 test.txt

–full-time 参数:

$ ls --full-time
total 0
-rw-r--r-- 1 gps gps 0 2012-06-12 16:21:15.550557727 +0800 README.txt
-rw-r--r-- 1 gps gps 0 2012-06-12 16:21:23.720354220 +0800 test.txt

stat 命令:

$ stat test.txt
  File: `test.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d      Inode: 4980751     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     gps)   Gid: ( 1000/     gps)
Access: 2012-06-12 16:21:23.720354220 +0800
Modify: 2012-06-12 16:21:23.720354220 +0800
Change: 2012-06-12 16:21:23.720354220 +0800

$ touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.

A FILE argument that does not exist is created empty, unless -c or -h
is supplied.

A FILE argument string of - is handled specially and causes touch to
change the times of the file associated with standard output.

Mandatory arguments to long options are mandatory for short options too.
  -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
      --help     display this help and exit
      --version  output version information and exit

Note that the -d and -t options accept different time-date formats.

Report touch bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'touch invocation'

touch修改文件的修改时间和访问时间,ls --full-time显示文件详细,stat命令的更多相关文章

  1. python 修改文件的创建时间、修改时间、访问时间

    目录 python 修改文件创建.修改.访问时间 方案一 方案二(无法修改文件创建时间) python 修改文件创建.修改.访问时间 突如其来想知道一下 python 如何修改文件的属性(创建.修改. ...

  2. VC++ 获取文件属性创建时间、修改时间和访问时间

    转载:http://blog.sina.com.cn/s/blog_66bf8d8301014ikd.html WIN32_FIND_DATA结构 关于文件的全部属性信息,总计有以下以下9 种:文件的 ...

  3. Linux学习笔记:touch新建文件、修改访问、改动时间

    touch用于创建新的空文件或者修改已有文件的时间戳. 语法:touch file.txt 如果file存在,使用touch指令可更改这个文件或目录的日期时间,包括存取时间和更改时间. 如果file不 ...

  4. Python 获取文件的创建时间,修改时间和访问时间

    # 用到的知识# os.path.getatime(file) 输出文件访问时间# os.path.getctime(file) 输出文件的创建时间# os.path.getmtime(file) 输 ...

  5. C# 读取文件的修改时间、访问时间、创建时间

    C# 获取文件的各个时间如下: 表2<ccid_nobr> 属性 功能和用途 Attributes 返回和文件相关的属性值,运用了FileAttributes枚举类型值 CreationT ...

  6. Web 在线文件管理器学习笔记与总结(2)显示文件列表(名称,类型,大小,可读,可写,可执行,创建时间,修改时间,访问时间)

    主要函数: filetype() 判断文件类型 filesize() 得到文件大小(字节) is_readable() 判断文件是否可读 is_writeable() 判断文件是否可写 is_exec ...

  7. python 获取文件大小,创建时间和访问时间

    # -*- coding: UTF8 -*- import timeimport datetime import os 1. '''把时间戳转化为时间: 1479264792 to 2016-11-1 ...

  8. c++ 获取文件创建时间、修改时间、访问时间、文件内容长度

    int GetFileInfo(string& strPath, int& iCreateTime, int& iModifyTime, int& iAccessTim ...

  9. windows修改文件的修改或者创建时间

    https://www.online-tech-tips.com/computer-tips/how-to-change-the-last-modified-date-creation-date-an ...

随机推荐

  1. TCP连接状态具体解释

    tcp状态: LISTEN:侦听来自远方的TCPport的连接请求 SYN-SENT:再发送连接请求后等待匹配的连接请求 SYN-RECEIVED:再收到和发送一个连接请求后等待对方对连接请求的确认 ...

  2. 用lisp来让计算机学会写作

    大部分的代码.思路参考了<Ansi Common Lisp>P138~P141. 问题:给一篇英文文本,如何让计算机依据此文本而生成随机但可读的文本.如: |Venture| The Na ...

  3. HDU1686——Oulipo

    Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...

  4. SQL窗体函數一例

    需求: MSSQL,列出服務實例中全部數據庫的例如以下信息: 數據庫ID.數據庫名.創建日期.數據文件類型.數據文件大小.數據庫總大小.文件所在路徑. 寫法(後面的百分比為所花時間占比): -- 连接 ...

  5. Linq To sql入门练习 Lambda表达式基础

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  6. 【linux】内核源代码下载与阅读

      原创,转载时请注明,谢谢.邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http://blog. ...

  7. javascript 中对this关键字的一些理解

    var self = this 可能会觉得奇怪为什么我会定义一个_self的变量, 因为在js里,this不用对于其他的对象语言,他的解析过程与运行过程中this会改变的.这里简单说说js里this的 ...

  8. event.srcElement获得引发事件的控件(表单)

    <1> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  9. ALV前导零的问题

    ALV的IT_FIELDCAT参数中L_ZERO 选项置位的话,对NUM类型的前导0是可以输出的,但是有个很重要的前提条件,NO_ZERO不可以置位,否则L_ZERO是失效的.

  10. vim 操作指令2

    VIM命令大全 光标控制命令 命令 光标移动 h 向左移一个字符 j 向下移一行 k 向上移一行 l 向右移一个字符 G 移到文件的最后一行 w 移到下一个字的开头 W 移到下一个字的开头,忽略标点符 ...