ssh主机的历史记录| 尾巴'不产生任何输出

jon*_*rry 3 ssh bash

谁能解释以下内容?当我使用ssh远程执行历史记录时,不会产生任何输出,甚至其他远程命令也会产生输出,并且该计算机上存在历史记录。

ssh host 'history | tail' # produces no output
ssh host 'echo foo | tail' # produces 'foo' as output
ssh host
> history | tail # produces expected output
Run Code Online (Sandbox Code Playgroud)

Pau*_*ce. 5

非交互式shell的历史记录未加载。您可以tail历史记录文件(~/.bash_history)或打开历史记录并加载它。

set -o history
history -r
Run Code Online (Sandbox Code Playgroud)

从远程主机执行此操作所需的完整命令如下:

ssh host 'HISTFILE=~/.bash_history; history -r; history' | tail
Run Code Online (Sandbox Code Playgroud)