在Ruby中创建一个空文件:相等的? [英] Creating an empty file in Ruby: "touch" equivalent?
本文介绍了在Ruby中创建一个空文件:相等的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ruby中创建空文件的最佳方法是什么?
What is the best way to create an empty file in Ruby?
与Unix命令类似的触摸:
Something similar to the Unix command, touch:
touch file.txt
推荐答案
FileUtils.touch
看起来像什么并镜像 * touch
命令:
require 'fileutils'
FileUtils.touch('file.txt')
*与 touch(1)不同,您不能单独更新mtime或atime.它还缺少其他一些不错的选择.
* Unlike touch(1) you can't update mtime or atime alone. It's also missing a few other nice options.
这篇关于在Ruby中创建一个空文件:相等的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文