如何使用Bash在屏幕会话中获取命令历史记录? [英] How do I get the command history in a screen session using Bash?
问题描述
如果我使用 screen -dmS名称
启动屏幕会话,我将如何使用脚本访问该屏幕会话的命令历史记录?
If I start a screen session with screen -dmS name
, how would I access the command history of that screen session with a script?
使用↑,即使在屏幕上,也会显示最后执行的命令。
Using the ↑, the last executed command appears, even in screen.
推荐答案
屏幕
不会保留您键入的命令的历史记录。您的外壳可能保留也可能不保留历史。由于您似乎使用了 bash
,因此可以使用 history
命令。
screen
doesn't maintain a history of the commands you type. Your shell may or may not keep a history. Since you appear to use bash
, you can use the history
command.
屏幕
似乎与历史搜索大致相似(它只是在回滚缓冲区中搜索命令行。请参见屏幕历史命令下的手册页(默认情况下绑定到
Ca {
)。
screen
does appear to have a crude approximation of a history search (it merely searches the scrollback buffer for a command line. See the screen
man page under the "history" command (bound to C-a {
by default).
这篇关于如何使用Bash在屏幕会话中获取命令历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!