linux touch使用教程,Linux touch 命令使用介绍

Linux touch 命令使用介绍

本文给大家介绍了一些touch命令的用法。touch一般用来创建一个新文件。同时,touch还可以用来修改文件时间戳。

创建新文件:$ ls -l /tmp/foo

ls: /tmp/foo: No such file or directory

$ touch /tmp/foo

$ ls -l /tmp/foo

-rw-r--r--  1 andy  wheel  0 Jul 10 11:56 /tmp/foo

touch还可以用来修改文件时间戳。

-t 参数可以指定要修改成的具体时间$ ls -l /tmp/foo

ls: /tmp/foo: No such file or directory

$ touch -t 201107010930 /tmp/foo

$ ls -l /tmp/foo

-rw-r--r--  1 andy  wheel  0 Jul  1 09:30 /tmp/foo

若没有指定,则设置为当前时间:$ ls -l /tmp/foo

-rw-r--r--  1 andy  wheel  0 Jul  1 09:30 /tmp/foo

$ touch /tmp/foo

$ ls -l /tmp/foo

-rw-r--r--  1 andy  wheel  0 Jul 10 11:58 /tmp/foo

You can also use the timestamp from another file and apply it to another file by using the -r switch.$ ls -l /tmp/someotherfile

-rw-r--r--  1 andy  wheel  0 Aug 12  2005 /tmp/someotherfile

$ touch -r /tmp/someotherfile /tmp/foo /tmp/foo2 /tmp/foo3

$ ls -al /tmp/

-rw-r--r--  1 andy  wheel  0 Aug 12  2005 /tmp/foo

-rw-r--r--  1 andy  wheel  0 Aug 12  2005 /tmp/foo2

-rw-r--r--  1 andy  wheel  0 Aug 12  2005 /tmp/foo3

-rw-r--r--  1 andy  wheel  0 Aug 12  2005 /tmp/someotherfile

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值