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. c++11 新特性之 autokeyword

    C++11是对眼下C++语言的扩展和修正.C++11包含大量的新特性:包含lambda表达式,类型推导keywordauto.decltype,和模板的大量改进. g++编译c++11命令加上 -st ...

  2. 配置SAP 采购合同审批

    需求: 采购合同类型是MK,采购组织是POSC,采购组PGC,标识:估计价格是空,总价有值0.00 - 9999999999.00 RMB 满足以上条件的时候需要审批该合同. 配置: spro-> ...

  3. 利用Winscp,Putty实现Windows下编写Linux程序

    本文讲的方案实现以下功能:利用winscp和putty的脚本功能,实现在Window平台上编写代码,上传到Linux进行编译,然后取编译结果.需要用到3个文件,分别如下: (1) synchroniz ...

  4. [Cocos2d-x开发问题-3] cocos2dx动画Animation介绍

    Cocos2d-x为了减少开发难度,对于动画的实现採用的帧动画的方案.这也就是说Cocos2d-x中的动画是帧动画. 帧动画的原理相信大家都不陌生,就是多张图片循环播放以实现动画的效果. 一个简单的动 ...

  5. Java学习——何为JNDI

    曾记得在做机房收费系统的时候就接触到了API,由于它的功能非常强大,可是自己对它却不怎么了解.所以当时是又爱又怕.现在,一路走来才明确,事实上它就是一组接口.仅仅要我们去了解它就会发现.它事实上也没想 ...

  6. spring 整合redis

    用的是最新的jedis-2.6.2.jar这个包,这个和以前的有点不同.还需要添加spring-data-redis-1.2.1.RELEASE.jar和commons-pool2-2.3.jar. ...

  7. CentOS查看端口是否被占用

    CentOS查看端口是否被占用 本文介绍了linux中查看某一端口是否被占用的方法,有关netstat命令的使用技巧,感兴趣的朋友可以参考下. 使用命令: netstat -tunlp 会显示所有端口 ...

  8. JENKINS 打包发布脚本

    #!/bin/bash #nohup bash check_new_pkgs_dev.sh & #steps below: ##发布的机器上运行这个脚本 #定时遍历发布包存放路径 #1.遍历所 ...

  9. 基于visual Studio2013解决面试题之0602全排列

     题目

  10. Mac上利用Eclipse编译Cocos2d-x

    目前使用较多的Cocos2d-x开发平台是XCode,应该是由于大部分Cocos2d-x开发者都是iOS开发出生.但是当我们将XCode开发的Cocos2d-x工程发布Android版本时,每次都需要 ...