How do I redirect history to a file?

command-line

Solution

Just do `history > history.txt` without the echo. That should do it. When you do echo history, you are telling unix to print history to screen rather then execute it, which is why `echo history > history.txt` only contains the word history.

Problem

Is it possible to put the output of a command into a file? I tried doing a ` echo history > history.txt ` But it put the text history instead into that file.

Original source