bash输出到文件
我有以下语句
for i in `cat i.txt`; do wine ~/run.exe $i.asc >> out.asc; done
,但它不断将所有输出写入控制台而不是文件“out.asc”。请您帮我将输出重定向到文件而不是屏幕。提前致谢!
i have the following statement
for i in `cat i.txt`; do wine ~/run.exe $i.asc >> out.asc; done
but it keeps writing all the output to console not the file 'out.asc'. plz can you help me to redirect the output to file rather than screen. thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可能是 wine 正在写入 stderr,因此您需要重定向:
注意
2>>
运算符中的 2,这意味着 stderr。It might be that wine is writing to stderr, so you need to redirect that:
Notice the 2 in the
2>>
operator, this means stderr.尝试将 stderr (2) 重定向到 stdout (1)
try with redirecting stderr (2) to stdout (1)
也许您既有标准输出又有错误输出。使用
>>
和2>>
将两个输出流重定向到您的文件。您可以选择将源重定向到不同的文件:
Maybe you have both a standard output and erro outputs. Use
>>
and2>>
to redirect both output stream to your file.You could optionally redirect sources to different files:
其他人已经回答了您的实际问题,我想展示一个更好的习惯用法来读取文件的行。
而不是
尝试
Other have answered your actual question, I'd like to show a better idiom to read the lines of a file.
Instead of
Try