tee 命令是否总是等待 EOF?
我想将命令的输出记录到 stdout 以及日志文件中。 我已经安装了 Cygwin,并且正在尝试使用 tee
命令来完成此操作。
devenv mysolution.sln /build myproject "Release|Win32" | tee build.log
问题在于,tee 似乎坚持在将任何内容输出到 stdout 或日志文件之前等待文件末尾。 这消除了所有的要点,即有一个日志文件供将来参考,但也有一些 stdout
日志记录,以便我可以轻松地查看构建进度。
tee
的选项似乎仅限于 --append
、--ignore-interrupts
、--help
和--版本
。 那么还有另一种方法可以实现我想要做的事情吗?
I'd like to log the output of a command to stdout
as well as to a log file. I've got Cygwin installed and I'm trying to use the tee
command to accomplish this.
devenv mysolution.sln /build myproject "Release|Win32" | tee build.log
Trouble is that tee
seems to insist on waiting for the end of file before outputting anything to either stdout
or the log file. This takes away the point of it all, which is to have a log file for future reference, but also some stdout
logging so I can easily see the build progress.
tee
's options appear to be limited to --append
, --ignore-interrupts
, --help
, and --version
. So is there another method to get to what I'm trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这绝对不应该发生——它会让 T 恤几乎毫无用处。 这是我编写的一个简单测试,用于对此进行测试,并且它绝对不会等待 eof。
This should definitely not be happening - it would render tee nearly useless. Here's a simple test that I wrote that puts this to the test, and it's definitely not waiting for eof.
您可以输出到文件并 tail -f 文件。
devenv mysolution.sln /build myproject "Release|Win32" > 构建.log &
tail -f 构建.log
You can output to the file and tail -f the file.
devenv mysolution.sln /build myproject "Release|Win32" > build.log &
tail -f build.log
自己写吧! (这里的重点是自动刷新 (
$|
) 设置已打开,因此看到的每一行都会立即刷新。这可能是真正的tee
命令所缺少的.)您可以将脚本命名为您想要的任何名称。 我称之为
perlmilktee
! :-PWrite your own! (The point here is that the autoflush (
$|
) setting is turned on, so every line seen is flushed straight away. This may perhaps be what the realtee
command lacked.)You can call the script anything you want. I call it
perlmilktee
! :-P