Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

for example: when

ssh xxx@192.168.0.123 "histroy"

it get nothing,

but when

ssh xxx@192.168.0.123

and then

history

it get a lot.

any one tell me how to get the history by one line command?

share|improve this question

migrated from stackoverflow.com Oct 26 '11 at 19:51

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 2 down vote accepted
ssh xxx@192.168.0.123 'export HISTFILE=~/.bash_history; set -o history; history'
share|improve this answer
    
wow, works like magic! –  yeer Oct 26 '11 at 6:34
    
@yeer ssh xxx@192.168.0.123 "cat ~/.bash_history | nl" also works, try that out. –  chown Oct 26 '11 at 18:34
    
Could you provide some explanation about what your code does? –  Tom Wijsman Nov 1 '11 at 14:06

You can cat the file that the history command reads from and then number each line:

ssh xxx@192.168.0.123 "cat ~/.bash_history | nl"
share|improve this answer
    
yes, but it can not get the time stamps. –  yeer Oct 26 '11 at 3:05
    
did not work :( –  yeer Oct 26 '11 at 4:04
    
hi chown, i did not add any formatting, i wanna to see the output first, the formatting is secondary. –  yeer Oct 26 '11 at 6:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.