Grep 最后一行输出
Grep the last lines of ouput
当 运行在没有重定向的情况下使用 shell 命令时,我有时 事后看来 想要处理我在屏幕上看到的输出。
事后看来,我经常想“grep”控制台的输出。我可能无法通过正确的重定向再次 运行 命令:(该命令可能需要很长时间才能 运行。该命令可能会产生副作用)。
是否有一些 shell 魔法可以用来:“在终端中搜索最后 100 行输出”,无需再次重新执行命令使用重定向?
我目前的解决方案是手动向上滚动,然后将最后几行输出复制粘贴到一个文本文件中。我更喜欢完全脚本化的解决方案...
Is there some shell wizardry which I could use to: "Grep the last 100 lines of output in the terminal", without re-executing the command again with a redirect?
没有
My current solution is to scroll up manually, and copy paste the last lines of output into a text file. I would prefer a fully scripted solution instead...
确切地说,您必须使用用于查看 输出的程序,可以是图形环境中的图形终端。一些这样的终端允许将终端输出的当前“状态”保存到文件中。下次 - 使用 tmux
或 screen
- 即模拟终端的程序。
当 运行在没有重定向的情况下使用 shell 命令时,我有时 事后看来 想要处理我在屏幕上看到的输出。
事后看来,我经常想“grep”控制台的输出。我可能无法通过正确的重定向再次 运行 命令:(该命令可能需要很长时间才能 运行。该命令可能会产生副作用)。
是否有一些 shell 魔法可以用来:“在终端中搜索最后 100 行输出”,无需再次重新执行命令使用重定向?
我目前的解决方案是手动向上滚动,然后将最后几行输出复制粘贴到一个文本文件中。我更喜欢完全脚本化的解决方案...
Is there some shell wizardry which I could use to: "Grep the last 100 lines of output in the terminal", without re-executing the command again with a redirect?
没有
My current solution is to scroll up manually, and copy paste the last lines of output into a text file. I would prefer a fully scripted solution instead...
确切地说,您必须使用用于查看 输出的程序,可以是图形环境中的图形终端。一些这样的终端允许将终端输出的当前“状态”保存到文件中。下次 - 使用 tmux
或 screen
- 即模拟终端的程序。