php touch 创建目录,linux创建文件(touch)命令详解

Linux 创建文件命令主要用到的是 touch 命令,touch 命令可用来修改文件的访问时间,修改时间,如果没有指定时间,则默认为当前时间,如果指定的文件不存在,则 touch 命令将创建该文件。

命令格式:

touch

[-acfm]

[-r file(参照文件)]

[-t decimtime(时间值)]

[-d time(时间值)]

[--time={atime,access,use,mtime,modify}]

[--date=time]

[--reference=file]

[--no-create] 不建立任何文件,与 -c 作用想用

[--help] 在线帮助

[--version] 显示版本信息

[--]

file(文件)...

-a 修改文件 file 的存取时间.

-c 不创建文件 file.

-m 修改文件 file

-r ref_file 将参照文件 ref_file 相应的时间戳记的数值作为指定文件 file 时间戳记的新值.

-t time 使用指定的时间值 time 作为指定文件 file 相应时间戳记的新值,格式可以是 MMDDhhmm 或者 yyyyMMDDhhmm

例如:

touch -t 10112200 phpernote.com 将 phpernote.com 文件的时间更改为当年的10月11号22点整

touch -t 200910112200 phpernote.com 将 phpernote.com 文件的时间更改为2009年10月11日22点整

touch -r baidu.com phpernote.com 将 phpernote.com 文件的时间更改为和 baidu.com 文件的时间相同

touch phpernote.com 创建 phpernote.com 文件(文件时间默认为当前时间)

当然 Linux 创建文件的命令还有如:cp(拷贝文件) ,mv(移动文件) 也算是吧。

另外只要命令能够重定向输出到一个不存在的文件中去,那么该命令也能够创建文件,比如如下命令:

echo hello world > /home/phpernote.com 将字符串输出到 /home/phpernote.com 文件里面

cat baidu.com > /home/phpernote.com 将 baidu.com 文件里面的内容输出到 /home/phpernote.com 文件里面

less testless > /home/phpernote.com

tail -f -n 20 /home/phpernote.com > /home/phpernote.com

等等很多。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值