Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2980134
  • 博文数量: 272
  • 博客积分: 5544
  • 博客等级: 大校
  • 技术积分: 5496
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 00:48
个人简介

  每个人都要有一个骨灰级的爱好,不为金钱,而纯粹是为了在这个领域享受追寻真理的快乐。

文章分类

全部博文(272)

文章存档

2015年(2)

2014年(5)

2013年(25)

2012年(58)

2011年(182)

分类: LINUX

2011-05-16 16:18:59


命令名称:touch
使用权限:所有使用者
使用方式:

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 ...]
 
说明:
touch 指令改变档案的时间记录。 ls -l 可以显示档案的时间记录。
参数:
a 改变档案的读取时间记录。
m 改变档案的修改时间记录。
c 假如目的档案不存在,不会建立新的档案。与 --no-create 的效果一样。
f 不使用,是为了与其他 unix 系统的相容性而保留。
r 使用参考档的时间记录,与 --file 的效果一样。
d 设定时间与日期,可以使用各种不同的格式。
t 设定档案的时间记录,格式与 date 指令相同。
--no-create 不会建立新档案。
--help 列出指令格式。
--version 列出版本讯息。
 
范例:
最简单的使用方式,将档案的时间记录改为现在的时间。若档案不存在,系统会建立一个新的空档案(0 byte)。
touch file
touch file1 file2
 
将 file 的时间记录改为 5月6日18点3分,公元两千年。时间的格式可以参考 date 指令,至少需输入MMDDHHmm ,就是月日时与分。
touch -c -t 05061803 file
touch -c -t 050618032000 file
 
将 file2 的时间记录改变成与 file1 一样。
touch -r file1 file2
 
将 file 的时间记录改成 5月6日18点3分,公元两千年。时间可以使用 am, pm 或是24小时的格式,日期可以使用其他格式如 6 May 2000 。甚至支持"2 days ago"这样的格式。
touch -d "6:03pm" file
touch -d "05/06/2000" file
touch -d "6:03pm 05/06/2000" file
touch -d "2 days ago" file

find /etc -name * -exec touch {};
就可以把设定档的时间更新到与现在一致了。
阅读(1576) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~