赞 | 0 |
VIP | 2 |
好人卡 | 27 |
积分 | 1 |
经验 | 26327 |
最后登录 | 2019-10-13 |
在线时间 | 953 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 120
- 在线时间
- 953 小时
- 注册时间
- 2007-4-25
- 帖子
- 805
|
Dir 类里有不少接口可以用来进行与目录相关的操作:
http://ruby-doc.org/core/classes/Dir.html
比如 Dir.foreach 就可以迭代某目录下每一个文件的名字(如果是文件夹,可以进行递归),进行搜索。
要是图省事,也可以通过 MS-DOS 的 find 命令间接查找:FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]
/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search. |
|