通过管道传输到 find 的过滤任务列表不显示控制台输出?
Windows XP Pro
这在控制台中显示输出:
dir | find " free"
这不:
tasklist | find "Image Name"
这确实:
tasklist | find /C "Image Name"
这确实将预期的行写入文件:
tasklist | find "Image Name" > foo.txt
是什么原因导致的?
Windows XP Pro
This shows output in the console:
dir | find " free"
This doesn't:
tasklist | find "Image Name"
This does:
tasklist | find /C "Image Name"
And this does write the expected line into the file:
tasklist | find "Image Name" > foo.txt
What causes that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里无法重现。您的第二个命令行确实按预期工作,这样当第四个命令行将该行写入文件时就不会出现混乱。
当您搜索
" free"
时,字符串中是否仍然有前导空格可以从上一行开始搜索?Can't reproduce here. Your second command line does work as expected and that way no confusion arises when the fourth one writes that line into a file.
Did you perhaps still have the leading space in the string to search from the previous line when you searched for
" free"
?findstr 怎么样?你尝试过吗?
what about findstr? have you tried?
如果 /C 标志显示找到了特定行,则“find”返回的字符串可能以某种方式被剥离(或作为字符串中的特殊字符)并且仅显示字符串的末尾?如果调整命令行窗口的大小会发生什么?
这是一个修复:
任务列表 |找到“3184”|排序
if /C flag showed that a particular line was found, maybe the string returned by 'find' was somehow stripped (or there as a special character in the string) and only the end of the string was displayed? What would happen if you'd resize the command line window?
Here is a fix:
tasklist | find "3184" | sort
感谢 Stack Overflow,我有一段时间了解到这个问题的答案后退。 (显然我应该在这里发表评论而不是回答,但我还没有代表。)阅读链接,但摘要是tasklist.exe的输出有一些非打印垃圾,可以通过重定向标准错误来修复到 NUL:
tasklist.exe 2>NUL |找到“图片名称”
Thanks to Stack Overflow, I learned the answer to this question a while back. (Apparently I should probably comment instead of answer here, but I don't have the rep yet.) Read the link, but the summary is that the output of tasklist.exe has some non-printing garbage that is fixed by redirecting standard error to NUL:
tasklist.exe 2>NUL | find "Image Name"