Output of last shell command

前端 未结 11 1521
渐次进展
渐次进展 2020-12-29 02:49

Not until midway through a 3 hour build script, I\'ll remember that I want to see something at the beginning of the output after it\'s done. At this point I\'ve exceeded th

相关标签:
11条回答
  • 2020-12-29 03:01

    My be you can use tee command to put the output to STDOUT as well to a file and then use it.

    0 讨论(0)
  • 2020-12-29 03:02

    If you're looking purely for the return code of the last executed command, use echo $?.

    This usually helps when you want to find whether your last command executed successfully and you could also mould this into your build script for pass/fail alerts.

    0 讨论(0)
  • 2020-12-29 03:11

    save output as a variable?

    bash: Output=$(ls); echo $Output
    
    0 讨论(0)
  • 2020-12-29 03:13

    script(1) is exactly what you need:

    script
    make
    exit
    vim typescript
    

    The script program will start a new shell and save input and output to the typescript file. When you're done, just close the shell with exit or ^D. If you'd rather not start a new shell but just run your build, you can use: script -c <command>.

    0 讨论(0)
  • This is a function of your terminal. You should focus on creating a setup where you don't have to remember to do anything. One possible solution is to launch "screen" in your login script (which is not so easy to get right) with logging enabled.

    0 讨论(0)
提交回复
热议问题