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?

link|improve this question
feedback

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

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

2 Answers

up vote 2 down vote accepted
ssh xxx@192.168.0.123 'export HISTFILE=~/.bash_history; set -o history; history'
link|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
feedback

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"
link|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
feedback

Your Answer

 
or
required, but never shown