export bash history to file

Hi,
I want to export bash history to a file, I used the following command

 history > /home/administrator/bashHistory 

But the exported file only contains commands with line number from 996 to the last one, How to export all the commands including commands before line 996?

Thanks a lot.
Roy987

The man page for history says that using a negative number as the first parameter on the command line (e.g. -1000) will print the most recent (1000 in this example) lines. This isn't working with my version of bash.

Bash keeps it's history in the clear, so you should be able to run this command:

grep -v "^#" $HISTFILE >output-file 

Hope this helps a bit.

EDIT:After some playing history 10000 printed my complete history (which is less than 10000 lines).

1 Like

Thanks a lot, this one

 grep -v "^#" $HISTFILE >output-file 

works for me.
Although,

history 10000

still outputs most recent 1000 lines on my machine.