每天一命令(6)touch (change file timestamps)1分钟

touch - change file timestamps

man touch

参  数:
 -a或--time=atime或--time=access或--time=use  只更改存取时间。 
 -c或--no-create 不建立任何文件。 
 -d<时间日期> 使用指定的日期时间,而非现在的时间。 
 -f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。 
 -m或--time=mtime或--time=modify 只更改变动时间。 
 -r<参考文件或目录> 把指定文件或目录的日期时间,统统设成和参考文件或目录的日期时间相同。 
 -t<日期时间> 使用指定的日期时间,而非现在的时间。 
 --help  在线帮助。 
 --version  显示版本信息。
创建文件 touch test.txt
root@guofeng  ~
# man touch

root@guofeng  ~
# touch test.txt

root@guofeng  ~
# ll
total 68
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   868 Jun  9 21:06 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
-rw-r--r--  1 root root     0 Jun 11 20:01 test.txt
修改文件的创建时间为当前的时间,touch -m test.txt
root@guofeng  ~
# ll
total 68
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   868 Jun  9 21:06 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
-rw-r--r--  1 root root     0 Jun 11 20:01 test.txt

root@guofeng  ~
# touch -m test.txt 

root@guofeng  ~
# ll
total 68
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   868 Jun  9 21:06 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
-rw-r--r--  1 root root     0 Jun 11 20:04 test.txt
touch -c a.txt 必须存在才会创建文件
root@guofeng  ~
# touch -c a.txt

root@guofeng  ~
# ll
total 68
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   868 Jun  9 21:06 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
-rw-r--r--  1 root root     0 Jun 11 20:04 test.txt

root@guofeng  ~
# touch -c test.txt

root@guofeng  ~
# ll
total 68
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   868 Jun  9 21:06 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
-rw-r--r--  1 root root     0 Jun 11 20:06 test.txt

其余的命令参数基本不用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值