I'm trying to call the following within a bash script:
`history -a current_history`
it is supposed to create the file with the commands executed this session.
Works perfectly fine in a shell environment
Does not work within a bash script
I see information which shows that you must call history differently within a bash script, as the following format:
#!/bin/bash
HISTFILE=~/.bash_history # Set the history file.
HISTTIMEFORMAT='%F %T ' # Set the hitory time format.
set -o history # Enable the history.
file="/media/saleel_almajd/Study/linux/my_scripts/history.txt"
history >> $file # Save the history.
but in doing so when modifying the last line to history -a
.
this then returns no results when compared to the regularly called history -a
file.
history -a ~/current_history