Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
誰でも次のことを説明できますか?ssh を使用して履歴をリモートで実行すると、出力が生成されず、他のリモート コマンドでも出力が生成され、そのマシンに履歴が存在します。
ssh host 'history | tail' # produces no output ssh host 'echo foo | tail' # produces 'foo' as output ssh host > history | tail # produces expected output
非対話型シェルの履歴はロードされません。tail履歴ファイル ( )を使用するか、履歴~/.bash_historyをオンにして読み込むことができます。
tail
~/.bash_history
set -o history history -r
リモート ホストからこれを行うために必要な完全なコマンドは次のとおりです。
ssh host 'HISTFILE=~/.bash_history; history -r; history' | tail