简体   繁体   English

如何将jar输出从ubuntu命令提示符重定向到文本文件

[英]How to redirect jar output from ubuntu command prompt to text file

I created jar file and I run it using command as follows: 我创建了jar文件,并使用以下命令运行它:

$ java -jar niidle.jar arguments...

it is showing correct output. 它显示正确的输出。 But I cant see the whole output. 但我看不到整个输出。 I want to see the whole output. 我想查看整个输出。 so how to redirect this whole thing to text file, when I run following command: 所以当我运行以下命令时,如何将整个事情重定向到文本文件:

$ java -jar niidle.jar arguments...

This should do !! 这应该做!

java -jar class.jar 2>> log.txt java -jar class.jar 2 >> log.txt

jar -jar niidle.jar arguments > output

If you do not need to save the output for future reference, you can read the full output this way: 如果不需要保存输出以供将来参考,则可以通过以下方式读取完整的输出:

java -jar niidle.jar arguments | less

Obviously, we are supposing that there is no user interaction. 显然,我们假设没有用户交互。 Otherwise you can do something like the following example to save the output and review it later. 否则,您可以执行以下示例,以保存输出并稍后进行检查。

java -jar niidle.jar arguments | tee output
... some user interaction ...
less output

要将错误日志保存在一个文件中,而普通控制台日志则保存在另一个文件中:

java -jar niidle.jar arguments 2> errorOutput.log > output.log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM