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.

How can I print Linux command line history without including the line numbers? I want to send it all to a text file like this:

history >> history.txt
share|improve this question
    
not quite what you want, but presumably you could strip out the line numbers with something like cut or awk. –  Journeyman Geek Aug 22 '11 at 2:10
    
On a side note, the history is already in a text file .bash_history in your home folder (at least on my ubuntu install) –  Col Aug 22 '11 at 6:07
1  
@Col That's true but it won't have your most recent history in a currently active shell. –  Keith Aug 22 '11 at 6:53
    
@Keith Good point, I forgot that. –  Col Aug 22 '11 at 10:25

2 Answers 2

up vote 3 down vote accepted

First of all, the history is a feature of the shell, and doesn't really have anything to do with Linux, per se. Assuming you are using the bash shell, if you just use the history write option it doesn't add line numbers, anyway.

history -w history.txt

Will get you what you want.

share|improve this answer

try the following if you don't want to write to a file

history -w /dev/stdout
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.