Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

for example: when

ssh xxx@ "histroy"

it get nothing,

but when

ssh xxx@

and then


it get a lot.

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

share|improve this question

migrated from Oct 26 '11 at 19:51

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

up vote 2 down vote accepted
ssh xxx@ '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@ "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@ "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

You must log in to answer this question.