【发布时间】:2015-09-08 08:22:38
【问题描述】:
我有一个应用程序日志,我正在尝试为其编写一个批处理文件,该文件将跟踪日志并返回包含“队列大小”的字符串,以便可以显示更新的队列大小。基本上相当于 Windows:
tail -f app.log | grep "queue size"
根据我的阅读,我需要使用 Windows PowerShell。我设计了以下脚本:
powershell -command Select-String -Path C:\logs\app.log -Pattern "queue size"
这给了我以下错误:
Select-String : A positional parameter cannot be found that accepts
argument 'size'. At line:1 char:1
+ Select-String -Path C:\logs\app.log -Pattern queue size
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Select-String], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SelectStringCommand
虽然这行不通,但它会根据当前逻辑不断更新吗?
【问题讨论】:
标签: powershell batch-file grep tail