先建立一个空白文件a.txt

1 [emduser@emd tmp]$ touch a.txt
2  
3 [emduser@emd tmp]$ ls -al a.txt
4  
5 -rw-rw-r-- 1 emduser emd 0 Dec 14 16:44 a.txt
利用stat命令查看文件a.txt的各种属性
01 [emduser@emd tmp]$ stat a.txt
02  
03   File: `a.txt'
04  
05   Size: 0               Blocks: 0          IO Block: 4096   regular empty file
06  
07 Device: fd00h/64768d    Inode: 654176      Links: 1
08  
09 Access: (0664/-rw-rw-r--)  Uid: (  501/ emduser)   Gid: (  506/     emd)
10  
11 Access: 2011-12-14 16:44:23.000000000 +0800
12  
13 Modify: 2011-12-14 16:44:23.000000000 +0800
14  
15 Change: 2011-12-14 16:44:23.000000000 +0800

上述最后三行的含义如下:

Access : 文件最近一次被访问的时间

Modify:  文件内容最近一次被修改的时间

Change: 文件属性最近一次被改变的时间

  • 假如用cat命令将文件a.txt的内容输出到终端( 执行 cat a.txt), 那么只有a.txt的Access就被刷新了
  • 假如我们把当前的时间追加到a.txt(执行 date >> a.txt) , 那么a.txt的Modify和Change都被刷新
  • 假如我们把a.txt的权限改为777(执行 chmod 777 a.txt) , 那么只有a.txt的Change被刷新
  • 假如我们用vi命令把文件a.txt打开, 然后保存退出,那么a.txt的Access,Modify和Change都被刷新
PS:  我们可以使用命令touch更新a.txt的Access和Modify时间,比如:
touch -d 1999-01-01 a.txt // 将a.txt的Access和Modify时间改为1999-01-01
touch -a a.txt  // 只将a.txt的Access时间改为当前系统时间
touch -m a.txt // 只将a.txt的Modify时间改为当前系统时间
当我们用ls -l a.txt看到的时间是Modify时间
 
PS: http://unix.stackexchange.com/questions/2464/timestamp-modification-time-and-created-time-of-a-file

There are 3 kind of "timestamps":

  • Access - the last time the file was read
  • Modify - the last time the file was modified (content has been modified)
  • Change - the last time meta data of the file was changed (e.g. permissions)

To display this information, you can use stat which is part of the coreutils.

stat will show you also some more information like the device, inodes, links, etc.

Remember that this sort of information depends highly on the filesystem and mount options. For example if you mount a partition with the noatime option, no access information will be written.

A utility to change the timestamps would be touch. There are some arguments to decide which timestamp to change (e.g. -a for access time, -m for modification time, etc.) and to influence the parsing of a new given timestamp. See man touch for more details.

touch can become handy in combination with cp -u ("copy only when the SOURCE file is newer than the destination file or when the destination file is missing") or for the creation of empty marker files.

The  field  st_atime  is  changed  by  file  accesses,  for example, by execve(2), mknod(2), pipe(2),
utime(2) and read(2) (of more than zero bytes).  Other routines, like mmap(2), may or may not  update
st_atime.

The  field st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2)
and write(2) (of more than zero bytes).  Moreover, st_mtime of a directory is changed by the creation
or  deletion  of  files  in  that directory.  The st_mtime field is not changed for changes in owner,
group, hard link count, or mode.

The field st_ctime is changed by writing or by setting inode information (i.e.,  owner,  group,  link
count, mode, etc.).

[转] stat命令输出结果中, Access,Modify,Change的含义的更多相关文章

  1. pip freeze > requirements.txt` 命令输出文件中出现文件路径而非版本号

    pip freeze > requirements.txt 命令输出文件中出现文件路径而非版本号 解决办法: pip list --format=freeze > requirements ...

  2. Access, Modify, Change Time of Linux File

    All these 3 time can be viewed by "stat " command. Access time is influenced by read opera ...

  3. 如何将cmd中命令输出保存为TXT文本文件

    在使用Windows 中的cmd.exe工具时,有时候我们想要把我们的输入命令及结果保存起来, 但是用复制的方法过于麻烦:有时输出数据条数过大,会造成内容自动滚出屏幕,无法阅读,我们可将命令运行的结果 ...

  4. linux C程序中获取shell脚本输出(如获取system命令输出)

    转载自 http://blog.csdn.net/hjxhjh/article/details/7909518 1. 前言 Unix 界有一句名言:“一行shell脚本胜过万行C程序”,虽然这句话有些 ...

  5. 【Linux开发】将cmd中命令输出保存为TXT文本文件

    将cmd中命令输出保存为TXT文本文件 在网上看到一篇名为:"[转载]如何将cmd中命令输出保存为TXT文本文件" 例如:将Ping命令的加长包输出到D盘的ping.txt文本文件 ...

  6. 将 cmd 中命令输出内容保存为 TXT 文本文件

    如果执行的命令输出内容较多,那么 cmd 控制台将会自动清除前面的内容,那么如何将屏幕的所有内容导出到文本文件? 下面给出简单的演示例子 ping百度,不会自动结束,按 Ctrl+C 强制结束,pin ...

  7. [20191119]探究ipcs命令输出.txt

    [20191119]探究ipcs命令输出.txt $ man ipcsIPCS(8)                    Linux Programmer's Manual              ...

  8. shell 脚本之获取命令输出字符串以及函数参数传递

    在ubuntu 14.04之后,所有的U盘挂载也分用户之分,最近很多操作也和U盘有关,所以就研究了一上午shell脚本函数以及字符串操作的方法. 字符串操作: 获取他的命令输出比较简单,打个简单的比方 ...

  9. linux top命令中各cpu占用率含义

    linux top命令中各cpu占用率含义 [尊重原创文章摘自:http://www.iteye.com/topic/1137848]0.3% us 用户空间占用CPU百分比 1.0% sy 内核空间 ...

随机推荐

  1. hibernate_validator_04

    对象图--个人觉得就是关联验证 ean Validation API不仅能够用来校验单个的实例对象,还能够用来校验完整的对象图.要使用这个功能,只需要在一个有关联关系的字段或者属性上标注 @Valid ...

  2. javascript 原生 cookie 处理

    来自网络! function getCookie(name) { var start = document.cookie.indexOf(name + "="); var len ...

  3. jQuery toggle() 方法与实例以及代替方法。

    看<jQeury 权威指南>时看到这个toggle()方法.因为之前在慕课网学习接触过.发现两者讲的有细微的不同 以隐藏/显示目标元素效果为例,慕课网是这样讲解的 $("#cli ...

  4. ASP.NET MVC 缓存使用示例

    应该说,缓存的设计是一门较为复杂的学问,主要考虑的问题包括:要不要缓存?要缓存哪些数据?要缓存多少数据?要缓存多久?如何更新缓存(手动还是自 动)?将缓存放在哪里?本文将以较为通俗易懂的方式,来看一看 ...

  5. javascript知识图谱

  6. oracle删除互相关联的记录

    今天遇到一个问题,在数据库中删除一条记录,但是在删除的时候报错了,报出该记录已经被其他子记录引用,想了好久不知道怎么做,后来发现报错提示信息中会提示删除该记录时影响了那个约束条件,于是思路出来了: 1 ...

  7. PS抠图神器:KNOCKOUT 2.0

    从优设上转载~~太好用了,保存下来以备不时之需. 本人亲身实践~~先看使用成果~~哈哈~~ 原版图 : 抠过的图: 主要看飘逸的发丝~~~而且全程操作不超过5分钟!! 下载地址: http://vdi ...

  8. es6整理

    1.const和let let类似于var,不同的是let只在所在的代码段有效 for循环的计数器,就很合适使用let命令. let和var的区别: //变量i是var声明的,在全局范围内都有效.所以 ...

  9. UITableView的详细使用

    UITableView的详细使用   UITableView是app开发中常用到的控件,功能很强大,多用于数据的显示.下面以一个简单的实例来介绍tableview的基本用法.(适合新手,高手飘过) @ ...

  10. codevs 1107 等价表达式

    传送门 题解:第一眼这题好像非常难得样子,简直没有思路.但是这可以用栈带入特殊值来解决.这里用到两个栈,一个是存贮数字,另一个存贮运算符,按优先级进行运算.当读入的运算符比运算符栈的栈顶元素优先级低时 ...