Linux运维最佳实践pdf下载
命令新建一个不存在的文件或则更改文件时间戳的命令
格式:[选项]...文件...
参数:
-a或--time=atime或--time=access或--time=use只修改存取时间。
-c或--no-create不完善任何文档。
-d使用指定的日期时间,而非如今的时间。
-f此参数将忽视不予处理,仅负责解决BSD版本touch指令的兼容性问题。
-m或--time=mtime或--time=modify只更改变动时间。
-r把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。
-t使用指定的日期时间,而非如今的时间。
作用:
touch命令参数可修改文档或目录的日期时间linux 删除文件夹,包括存取时间和修改时间。
创建不存在的test2.txt文件
touchtest2.txt
[root@localhost d1]# touch test2.txt [root@localhost d1]# ll -rw-r--r-- 1 root root 0 06-04 14:01 test2.txt
2.更新时间戳
touch-rtest.txttest2.txt
[root@localhost d1]# ll -rw-r--r-- 1 root root 0 06-04 16:01 test2.txt -rw-r--r-- 1 root root 0 06-04 14:48 test.txt [root@localhost d1]# touch -r test.txt test2.txt [root@localhost d1]# ll -rw-r--r-- 1 root root 0 06-04 14:48 test2.txt -rw-r--r-- 1 root root 0 06-04 14:48 test.txt
3.设定文件时间戳
命令:
touch-t2.50test.txt
-ttime使用指定的时间值time作为指定文件相应时间戳记的新值.此处的time规定为如下方式的十补码数:
[[CC]YY]MMDDhhmm[.SS]
这儿centos修改时间命令,CC为年数中的前两位,即”世纪数”;YY为年数的后两位linux系统镜像下载,即某世纪中的年数.假若不给出CC的值,则touch将把年数CCYY限定在1969--2068之内.MM为月数,DD为天将把年数CCYY限定在1969--2068之内.MM为月数centos修改时间命令,DD为天数,hh为小时数(几点),mm为分钟数,SS为秒数.此处秒的设定范围是0--61,这样可以处理闰秒.这种数字组成的时间是环境变量TZ指定的时区中的一个时间.因为系统的限制,早于1970年1月1日的时间是错误的。
转载请标明:谷谷点程序»Linuxcentos命令(9):touch命令新建一个不存在的文件或则更改文件时间戳的命令