Redirect only the last line of STDOUT to a file

前端 未结 5 1153
清歌不尽
清歌不尽 2020-12-16 17:41

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         


        
5条回答
  •  臣服心动
    2020-12-16 18:32

    scalac ... | awk 'END{print>>"output.txt"}1'
    

    This will pipe everything through to stdout and append the last line to output.txt.

提交回复
热议问题