ディレクトリを作成する - Ruby Tips!

mkdir( string [, integer] ) → 0 click to toggle source Makes a new directory named by string , with permissions specified by the optional parameter anInteger . The permissions may be modified by the value of File.umask , and are ignored on NT. FileUtils. mkdir_p '/usr/local/lib/ruby' causes to make following directories, if they do not exist. /usr /usr/local /usr/local/lib /usr/local/lib/ruby. You can pass several directories at a time in a list. The Dir.mkdir can be used to create directories − Dir.mkdir("mynewdir") You can also set permissions on a new directory (not one that already exists) with mkdir − NOTE − The mask 755 sets permissions owner, group, world [anyone] to rwxr-xr-x where r = read, w = write, and x = execute. Dir.mkdir( "mynewdir", 755 ) Deleting a Directory We have a Dir class to work with directories in Ruby. #!/usr/bin/ruby Dir.mkdir "tmp" puts Dir.exists? "tmp" puts Dir.pwd Dir.chdir "tmp" puts Dir.pwd Dir.chdir '..' puts Dir.pwd Dir.rmdir "tmp" puts Dir.exists? "tmp" In the script we use four methods of the Dir class. Dir.mkdir "tmp" The mkdir method makes a new directory called tmp. How to Read Files In Ruby. You can read a file in Ruby like this: Open the file, with the open method. Read the file, the whole file, line by line, or a specific amount of bytes. Close the file, with the close method. Here is the process in detail. Use the File class to open a file: file = File.open("users.txt") FileUtils. mkdir_p ' /usr/local/lib/ruby ' causes to make following directories, if it does not exist. /usr /usr/local /usr/local/lib /usr/local/lib/ruby. You can pass several directories at a time in a list.

ruby 关于目录操作_hahhah_08的专栏-CSDN博 …

Ruby Dir 类和方法 | 菜鸟教程 Dir[pat]Dir::glob( pat)返回一个数组,包含与指定的通配符模式 pat 匹配的文件名:* - 匹配包含 null …

Linux mkdir命令 | 菜鸟教程 - RUNOOB.COM

ruby文件操作 - wangyuyu - 博客园 2013-12-2 · 本文摘自互联网.原文作者不详. 1.创建文件夹 Dir.new %%1 Dir::mkdir #不指定目录全名称时,缺省为工作目录 Dir::chdir() 改变当前脚本工作目录 FileUtils.mkdir 'test' Linux mkdir命令 | 菜鸟教程 - RUNOOB.COM Linux mkdir命令 Linux 命令大全 Linux mkdir命令用于建立名称为 dirName 之子目录。 语法 mkdir [-p] dirName 参数说明: -p 确保目录名称存在,不存在的就建一个。 实例 在工作目录下,建立一个名为 AAA 的子目录 : mkdir AAA 在工作目录下的 BBB 目录中 mkdir_常用命令_命令行工具ossutil_常用工具_对象 …