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. Linux - 输入输出流程序 代码(C)

    输入输出流程序 代码(C) 本文地址:http://blog.csdn.net/caroline_wendy 使用输入输出流,控制文件流. STDIN_FILENO,STDOUT_FILENO代表标准 ...

  2. 在Windows上使用CodeLite+MinGW+Clang进行开发

    前几天听说clang 3.4已经release了,然后我又手痒就折腾一下,在这里记录一下折腾的经过. 在以前就试过clang-cl+VC的开发环境,编译代码到是没发现什么大问题,有不少警告而已,不过c ...

  3. Android-x86 4.4-r5 发布,PC 上的安卓系统

    Android x86 即运行于 x86 PC上的Android操作系统,目前已经支持大部分安卓程序. Android X86平台是由Beyounn和Cwhuang主持设计的.项目的主要目的在于为X8 ...

  4. <?php echo "我的第一段 PHP 脚本!"; ?>

    <!DOCTYPE html><html><body> <?phpecho "我的第一段 PHP 脚本!";?> </body ...

  5. C/C++:多个.cpp文件包括同一个.h头文件定义方法

    本文解决multiple definition of `XX'的错误.[出于反爬虫的目的,你不是在http://blog.csdn.net/zhanh1218上看到的,肯定不是最新最全的.] 关于头文 ...

  6. Javascript关闭详细说明

    在我的博客:http://blog.csdn.net/u011043843/article/details/26148265中也有对闭包的解释 在javascript中闭包是一个非常不好理解的概念.可 ...

  7. Oracle基础知识笔记(10) 约束

    表尽管建立完毕了,可是表中的数据是否合法并不能有所检查,而假设要想针对于表中的数据做一些过滤的话,则能够通过约束完毕,约束的主要功能是保证表中的数据合法性,依照约束的分类,一共同拥有五种约束:非空约束 ...

  8. Struts 2中的constant详解

    通过对这些属性的配置,可以改变Struts 2 框架的一些默认行为,这些配置可以在struts.xml文件中完成,也可以在struts.properties文件中完成. 1.<constant ...

  9. <1> perl概述

    [root@wx03 1]# cat a1.pl $arr=[1,2,3,4,5,6]; print $arr->[4]."\n"; $hash={a=>1,b=> ...

  10. Linux编译多个不同目录下的文件以及静态库、动态库的使用

    先看两篇博文,作为基础知识.如果对C/C++编译链接过程都了解的话,可以跳过不看. http://www.firedragonpzy.com.cn/index.php/archives/2556 ht ...