不输出到 STDOUT 的程序的管道输出
假设我有一个程序输出到由(必需)参数提供的文件:
./foo -o bar.txt
有什么方法可以欺骗它输出到管道吗?这仅输出到名为 -
的文件。
./foo -o - | less
Say I have a program that outputs to a file which is provided by an (required) argument:
./foo -o bar.txt
Is there any way to trick it into outputting to a pipe? This just outputs to a file named -
.
./foo -o - | less
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
/dev/stdout
作为文件名:You can use
/dev/stdout
as the file name:随着文件的增长,这会将 bar.txt 的内容提供给过滤器:
This will feed the contents of bar.txt to filter as the file grows:
其他解决方案,创建命名管道:
other solution, create a named pipe: