powershell搜索文本文件中的多个单词 [英] powershell to search multiple words in a text file
问题描述
我有一个文本文件,它在应用程序启动时由应用程序自动生成。我希望powershell能够连续读取该文本文件(即使另一个应用程序将信息写入该文件),并在找到单词已启动后停止阅读。一旦它通过将其作为文件的结尾找到该特定单词,它应该找到并显示包含我指定的单词的行。
简而言之:1)Powershell连续读取文本文件,直到找到一个单词开始
2)从文件的开头找到一些单词(例如:info),然后显示包含该特定单词(info)的整行。
任何帮助都会非常感激..
I have a text file that is auto-generated by an application when it is started. I want powershell to read that text file continously(even while another application writes info into that file) and stop reading once it finds a word started. Once it finds that specific word by making it as an end of file, it should find and display the lines containing the words I specify.
In short: 1) Powershell to read the text file continuously until it finds a word started
2) Find for some words(eg:info) from start of file upto started and display the whole line containing that particular word(info).
Any help would be really appreciated..
推荐答案
找到解决方案:
Found out the solution:
key = Get-Content D:\ ReadLog\key.txt
Get-Content D:\ ReadLog \read.log -wait |
ForEach-Object {
foreach(
key = Get-Content D:\ReadLog\key.txt
Get-Content D:\ReadLog\read.log -wait |
ForEach-Object {
foreach(
word in
这篇关于powershell搜索文本文件中的多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!