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

2 Answers

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.

link|improve this answer
feedback

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

history -w /dev/stdout
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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