仅将STDOUT的最后一行重定向到文件 [英] Redirect only the last line of STDOUT to a file

查看:104
本文介绍了仅将STDOUT的最后一行重定向到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译Scala代码,并将输出控制台输出写入文件中.我只想将STDOUT的最后一行保存在文件中.这是命令:

I'm compiling Scala code and write the output console output in file. I only want to save the last line of the STDOUT in a file. Here is the command:

scalac -Xplugin:divbyzero.jar Example.scala >> output.txt

scalac -Xplugin:divbyzero.jar Example.scala的输出是:

The output of scalac -Xplugin:divbyzero.jar Example.scala is:

helex@mg:~/git-repositories/my_plugin$ scalac -Xplugin:divbyzero.jar Example.scala | tee -a output.txt
You have overwritten the standard meaning
Literal:()
rhs type: Int(1)
Constant Type: Constant(1)
We have a literal constant
List(localhost.Low)
Constant Type: Constant(1)
Literal:1
rhs type: Int(2)
Constant Type: Constant(2)
We have a literal constant
List(localhost.High)
Constant Type: Constant(2)
Literal:2
rhs type: Boolean(true)
Constant Type: Constant(true)
We have a literal constant
List(localhost.High)
Constant Type: Constant(true)
Literal:true
LEVEL: H
LEVEL: H
okay
LEVEL: H
okay
false
symboltable: Map(a -> 219 | Int | object TestIfConditionWithElseAccept2 | normalTermination | L, c -> 221 | Boolean | object TestIfConditionWithElseAccept2 | normalTermination | H, b -> 220 | Int | object TestIfConditionWithElseAccept2 | normalTermination | H)
pc: Set(L, H)

我只想保存pc:Set(L,H)在输出文件中,而不是其余部分.借助哪个命令,我可以实现我的目标?

And I only want to save pc: Set(L, H) in the output file and not the rest. With the help of which command I can achieve my goal?

推荐答案

只需将stdout通过tail -n 1传递到您的文件

Just pipe stdout through tail -n 1 to your file

这篇关于仅将STDOUT的最后一行重定向到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆