本文介绍了Powershell 拖尾多文件命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过以下命令拖尾一个文件:
I can tail one file via the following command:
Get-Content -Path C:\log1.txt -Tail 10 –Wait
如何将其扩展到多个文件,我尝试了以下方法但没有成功:
How do I extend this to multiple files, I have tried the following with no luck:
Get-Content -Path C:\log1.txt,C:\log2.txt -Tail 10 –Wait
这只会从第一个文件中获取更新,而不会从第二个文件中获取更新.
This will only pick up updates from the first file, not the second.
推荐答案
根据@mjolinor 的评论,我提出了以下似乎有效的方案,
Based on @mjolinor's comment, I have come up with the following that appears to work,
Workflow My-Tail
{
Param([string[]] $Path)
foreach -parallel ($file in $path)
{
Get-Content -Path $file -Tail 1 -Wait
}
}
My-Tail (dir C:\*.log -Include log1.txt,log2.txt)
但是,这会出现某种进度条...
However, this has some sort of progress bar that appears...
这篇关于Powershell 拖尾多文件命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!