在目录中搜索文件中的关键字 [英] Searching for Keywords in Files in a Dir

查看:104
本文介绍了在目录中搜索文件中的关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

脚本在目录中的文件中搜索关键字


基本上,脚本包含一个带有部件号的文件


我得到了一个带文件的目录我想逐行搜索文件,如果一行有部件号,我希望它将该行打印到一个outfile文件。


我做了这个脚本但是它找不到匹配的产品。

我给了一个else语句,当我注释掉else语句时,它只打印else语句,没有打印输出文件。


这是我正在使用的脚本,希望有人可以显示我出错的地方。在此先感谢。

script to search for keywords in files in a dir

Basically the script consists of a file with part numbers

I got a dir with files I want to search the files line by line and if a line has the part number I want it to print that line to an outfile file.

I did this script but it does not find matching products.
I aded an else statement and it only prints the else statements alone when i commented out the else statements nothing prints tot output file.

This is the script i am working with hopefully someone could show where i am going wrong. Thanks in advance.

展开 | 选择 | Wrap | 行号

推荐答案

这是一个单行文件吗? />
is this a one line file?

展开 | 选择 | Wrap | 行号


没有多行


尝试这个:

try this:

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


这篇关于在目录中搜索文件中的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆