系统之家 - 系统光盘下载网站!

当前位置:系统之家 > 系统教程 > Linux find命令

Linux find命令常见用法汇总(4)

时间:2014-12-04 10:34:34 作者:qipeng 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20141204/31867.html 手机查看 评论

  使用chown, chgrp, chmod命令可以很好的比较mtime和ctime

  chown改变一个文件的属主,用ctime可以找到,用mtime便找不到。

  试试看。

  多谢斑竹! 我是在 Solaris 上面试的。我是对 -ctime 不明白。

  试的结果如下:

  修改文件,-mtime 改了, -ctime 也会改。

  访问文件,-atime 改了, -ctime 没变。

  chown, chgrp, chmod,mv, 都会使 -ctime 改变,但不影响 -atime 和 -mtime.

  touch 可以改 -mtime and/or -atime,但 touch -a 只改访问时间时,-ctime也改了。

  touch -m 改修改时间时,-ctime当然也改了。

  好象还有别的很多东西可以令 -ctime 改变, 搞不清楚。

  有什么方法可以显示 -mtime,atime,ctime 吗?

  可以用 -ctime 来实现对目录的增量文件进行备份或 transfer 吗 ?

  多谢!

  没有什么工具显示,(可能是俺不知道)

  把下面程序里的st_mtime换成st_ctime,或st_atime便可以得到你要的了。

  #include

  int

  main (int argc, char **argv)

  {

  struct stat buf;

  char date[80];

  char fname[80];

  printf(”Enter filename (with full path) to check mtime : “);

  scanf(”%s“,fname);

  stat(fname, &buf);

  printf (”mtime (in sec) of %s = %ld\n“, fname, buf.st_mtime);

  strcpy(date, ctime((time_t *)&(buf.st_mtime)));

  printf (”mtime (in date) of %s = %s\n“, fname, date);

  }

  至于文件备份,有什么不可以的么?

  mtime ls -l 最近修改文件内容的时间

  atime ls -lu 最近访问文件的时间

  ctime ls -li 最近文件有所改变的状态 ,如文件修改,属性\属主 改变 ,节点 ,链接变化等 ,应该是不拘泥只是时间前后的改变

  俺看了ls的帮助,以为只是按ctime或atime排序,显示的时间还是mtime.

  仔细比较了一下,ayhan说的是对的。谢谢ayhan.

  多谢 ahyan 提示 ! 我在 Solaris 上试过如下:

  mtime 用 ls -l 看到

  atime 用 ls -lu 看到

  ctime 用 ls -lc 看到。 (ls -li 只有 inode number)

  摘书如下:

  -c Uses time of last modification of the i-node (file

  created, mode changed, and so forth) for sorting (-t)

  or printing (-l or -n)。

  -u Uses time of last access instead of last modification

  for sorting (with the -t option) or printing (with the

  -l option)。

  -i For each file, prints the i-node number in the first

  column of the report.

  上面就是Linux下find命令的常见用法的介绍了,所有会使用到的find都有提到,初学者如果对find命令不熟悉的话,不妨来详细了解下find命令。

发表评论

0

没有更多评论了

评论就这些咯,让大家也知道你的独特见解

立即评论

以上留言仅代表用户个人观点,不代表系统之家立场

其他版本软件

热门教程

人气教程排行

Linux系统推荐

官方交流群 软件收录