Touch (Unix)

touch是一个被用于更改文件访问和修改时间的标准UNIX程序,它也被用于创建新文件。

历史

touch程序最早出现在第七版AT&TUNIX,包含在GNU核心工具组的touch程序的作者为Paul Rubin,Arnold Robbins,Jim Kingdon,David MacKenzie。

使用方法

单一UNIX规范包含下列程序选项:

-a,只更改访问时间
-c,如果文件不存在,不创建且不声明
-m,只更改修改时间
-r file,使用file的访问、修改时间而非当前时间
-t time,使用time(格式见下)更改访问、修改时间

time的格式为[[cc]yy]MMDDhhmm[.ss],其中cc代表世纪,yy代表年份的后二位数字,MM代表月份,DD代表天数,hh代表小时,mm代表分钟,ss代表秒数。

其他Unix系统或类Unix系统可能添加额外的选项。

示例

以当前时间更改访问、修改时间:

$ touch myfile.txt

注意:touch不修改myfile.txt内容,只更改它的访问、修改时间,如果myfile.txt不存在,它会被创建。

用指定时间更改访问、修改时间:

$ touch -t 200701310846.26 index.html
$ touch -d '2007-01-31 8:46:26' index.html
$ touch -d 'Jan 31 2007 8:46:26' index.html

其他操作系统

其他操作系统,如(Windows、Mac OS)也存在执行相似功能的软件:

参看

外部链接

文档

  • GNU版本touch文档(页面存档备份,存于互联网档案馆
  • openBSD版本touch文档
文件系統
  • cat
  • cd
  • chmod
  • chown
  • chgrp
  • cksum
  • cmp
  • cp
  • dd
  • du
  • df
  • file
  • fsck
  • fuser
  • ln
  • ls
  • mkdir
  • mount
  • mv
  • pax英语pax (Unix)
  • pwd
  • rm
  • rmdir
  • size
  • split
  • stat
  • tee
  • touch
  • type英语type (Unix)
  • umask英语umask
程序
  • at
  • bg
  • chroot
  • cron
  • fg
  • kill
  • killall英语killall
  • nice
  • pgrep
  • pkill英语pkill
  • ps
  • pstree英语pstree
  • time
  • top
用户环境
  • clear
  • env
  • exit
  • history英语history (Unix)
  • id
  • logname
  • mesg英语mesg
  • passwd
  • su
  • sudo
  • uptime
  • talk英语talk (software)
  • tput英语tput
  • uname
  • w
  • wall英语wall (Unix)
  • who
  • whoami
  • write英语write (Unix)
文本编辑
  • awk
  • banner英语banner (Unix)
  • basename
  • comm英语comm
  • csplit英语csplit
  • cut
  • diff
  • dirname
  • ed
  • ex
  • fmt英语fmt
  • fold英语fold (Unix)
  • head英语head (Unix)
  • iconv
  • join英语join (Unix)
  • less
  • more
  • nl英语nl (Unix)
  • paste英语paste (Unix)
  • sed
  • sort英语sort (Unix)
  • spell英语spell (Unix)
  • strings英语strings (Unix)
  • tail
  • tr
  • uniq英语uniq
  • vi
  • wc
  • xargs
壳层内建
网络英语Network utility
查找
文档
  • apropos英语apropos (Unix)
  • help英语help (command)
  • man
软件开发
杂项
  • bc
  • cal
  • dc
  • expr
  • lp英语lp (Unix)
  • lpr
  • sleep
  • true和false
  • yes