0
或者其他任何建議,我只想檢查一個文件是否在給定的時間被重命名。當我在UNIX上重命名文件時,什麼時間戳會被更改
或者其他任何建議,我只想檢查一個文件是否在給定的時間被重命名。當我在UNIX上重命名文件時,什麼時間戳會被更改
之後你mv
該文件以其新名稱,touch
該文件。這將改變時間戳。舉個例子,我創建了3個文件a
,b
和c
(通過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
'd到aa
與原來的時間戳,然後touch
倒是得到新的時間戳。
當你重命名文件,走出了MAC時間只有C(變化)時間的變化:重命名的文件夾中
[[email protected] test]$ touch file_time
[[email protected] 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: -
[[email protected] test]$ mv -iv file_time file_time2
'file_time' -> 'file_time2'
[[email protected] 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: -
使用'LS -l'&查找您希望它重新命名的時間。 –
但我發現mv不會更改上次修改時間。 – neorc
啊是的,'mv'不會影響按照POSIX規則的時間戳。如果您使用'cp',它會影響時間戳。 –