在UNIX上重命名文件时,将更改哪个时间戳

时间:2013-10-04 02:58:18

标签: unix

或者任何其他建议,我只想检查文件是否在给定时间重命名。

2 个答案:

答案 0 :(得分:1)

在您将文件mv更改为新名称后,touch文件。这将改变时间戳。例如,我创建了3个文件abc(通过touch a b c

23:11:50 --> ls -l
total 0
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 a
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 b
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 c
23:11:52 --> mv a aa
23:12:18 --> ls -l
total 0
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 aa
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 b
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 c
23:12:21 --> touch aa
23:12:47 --> ls -l
total 0
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:12 aa
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 b
-rw-rw-r-- 1 kkanos kkanos 0 Oct  3 23:11 c

显然a mv'到aa带有原始时间戳,然后touch'd获取新的时间戳。

答案 1 :(得分:0)

重命名文件时,在其MAC时间之外,只有C(更改)时间发生变化:

[luke@ll test]$ touch file_time
[luke@ll test]$ stat file_time 
  File: 'file_time'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd04h/64772d    Inode: 33845249    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/    luke)   Gid: ( 1000/    luke)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2018-01-30 18:09:48.157529527 +0100
Modify: 2018-01-30 18:09:48.157529527 +0100
Change: 2018-01-30 18:09:48.157529527 +0100
 Birth: -
[luke@ll test]$ mv -iv file_time file_time2
'file_time' -> 'file_time2'
[luke@ll test]$ stat file_time2 
  File: 'file_time2'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd04h/64772d    Inode: 33845249    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/    luke)   Gid: ( 1000/    luke)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2018-01-30 18:09:48.157529527 +0100
Modify: 2018-01-30 18:09:48.157529527 +0100
Change: 2018-01-30 18:09:58.033633333 +0100
 Birth: -