Command history is only loaded in interactive sessions. Scripts don't run in interactive shells by default.
If you run the script with "
#!/bin/bash -i" at the top, the script's environment will be made interactive, and your (pre-existing) history file will be loaded into it. Then your history command will work as expected. Or just read the file directly, as repo showed above.
This will, however, only give you the history list from the last time the file was saved (usually at the close of the last session). To get your current shell's history you have to run the command directly in that shell.
Perhaps if you explained
why you want to display the history, we could help you to a proper solution. Maybe something involving a function in the current shell would do instead, for example?
PS: Please use
[code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.