To clear the bash history on a Linux or Unix system, you can use the history -c
command. This command will clear the current bash history and remove all entries from the history file.
Here's an example of how to use the history -c
command to clear the bash history:
history -c
This will clear the current bash history and remove all entries from the history file. Note that this will not affect the history of any other shells that are currently running on the system.
If you want to clear the history for all shells on the system, you can use the history -w
command to write the current history to the history file and then use the history -c
command to clear the history file. For example:
history -w history -c
This will write the current bash history to the history file and then clear the history file, effectively clearing the history for all shells on the system.