linux--文件時間

来源:互联网 发布:tv霸网络电视在线直播 编辑:程序博客网 时间:2024/05/17 20:28

linux下的文件有3個時間屬性:

access time (atime): 对文件访问的时间

modification time (mtime): 文件内容修改的时间

change time (ctime): 文件属性(权限,屬主)修改的时间。

注:一般mtime改变时ctime也会改变。 但ctime改變時atime不同步改變。

     可以使用stat命令查看上述的幾個時間。touch可以改變檔案的時間屬性,ls -l

     可以顯示檔案的時間記錄。

 

 

touch: 可以使用該命令修改文件的上述三個時間屬性(執行touch -d/touch -t更改時間會影響atime和mtime)

         結構語法:

            touch [-acfm]
                            [-r reference-file] [--file=reference-file]
                            [-t MMDDhhmm[[CC]YY][.ss]]
                            [-d time] [--date=time] [--time={atime,access,use,mtime,modify}] 
                             [-no-create] [--help] [--version] 
                             file1 [file2 ...] 
                       參數:a 改变档案的读取时间记录。 
                                m 改变档案的修改时间记录。 
                                c 假如目的档案不存在,不会建立新的档案。与 --no-create 的效果一样。 
                                f 不使用,是为了与其他 unix 系统的相容性而保留。 
                                r 使用参考档的时间记录,与 --file 的效果一样。 
                                d 设定时间与日期,可以使用各种不同的格式。
                                t 设定档案的时间记录,格式与 date 指令相同。
                                --no-create 不会建立新档案。
                                --help 列出指令格式。
                                --version 列出版本讯息。

*************************************************************

touch -d 和 date -t 的用法相同。

           常見格式:  touch -d "18:30" file
                           touch -d "6:30am" file
                           touch -d "05/06" file
                           touch -d " 20101229" file

 

 

 

 

 

原创粉丝点击