我在编译Scala代码并将控制台输出写入文件。我只想保存标准输出的最后一行到文件中。这是命令:
scalac -Xplugin:divbyzero.jar Example.scala >> output.txt
使用 scalac -Xplugin:divbyzero.jar Example.scala 命令的输出结果如下:
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)
我只想将 Set(L, H) 这一部分保存到输出文件中,而不是保存全部内容。请问我可以使用哪个命令实现我的目标?
我只希望在输出文件中保存 Set(L, H) ,而不是其他内容。我该使用哪个命令才能达到这个目的?
tail -1
同样有效。 - Martin Braun