系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux find命令

Linux find命令常見用法匯總(4)

時(shí)間:2014-12-04 10:34:34 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20141204/31867.html 手機(jī)查看 評論

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

  chown改變一個(gè)文件的屬主,用ctime可以找到,用mtime便找不到。

  試試看。

  多謝斑竹! 我是在 Solaris 上面試的。我是對 -ctime 不明白。

  試的結(jié)果如下:

  修改文件,-mtime 改了, -ctime 也會(huì)改。

  訪問文件,-atime 改了, -ctime 沒變。

  chown, chgrp, chmod,mv, 都會(huì)使 -ctime 改變,但不影響 -atime 和 -mtime.

  touch 可以改 -mtime and/or -atime,但 touch -a 只改訪問時(shí)間時(shí),-ctime也改了。

  touch -m 改修改時(shí)間時(shí),-ctime當(dāng)然也改了。

  好象還有別的很多東西可以令 -ctime 改變, 搞不清楚。

  有什么方法可以顯示 -mtime,atime,ctime 嗎?

  可以用 -ctime 來實(shí)現(xiàn)對目錄的增量文件進(jìn)行備份或 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 最近修改文件內(nèi)容的時(shí)間

  atime ls -lu 最近訪問文件的時(shí)間

  ctime ls -li 最近文件有所改變的狀態(tài) ,如文件修改,屬性\屬主 改變 ,節(jié)點(diǎn) ,鏈接變化等 ,應(yīng)該是不拘泥只是時(shí)間前后的改變

  俺看了ls的幫助,以為只是按ctime或atime排序,顯示的時(shí)間還是mtime.

  仔細(xì)比較了一下,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命令的常見用法的介紹了,所有會(huì)使用到的find都有提到,初學(xué)者如果對find命令不熟悉的話,不妨來詳細(xì)了解下find命令。

標(biāo)簽 Linux 命令

發(fā)表評論

0

沒有更多評論了

評論就這些咯,讓大家也知道你的獨(dú)特見解

立即評論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄