After reading some posts, could not figure out how comes history -d 1
in a function does not delete the entry.
The function below goes directly to the command line:
function test () {
echo "HISTFILE: '${HISTFILE}'"
history -d 1
}
Then we run:
history -c
echo "to remove"
history
1 echo "to remove"
2 history
echo $(test)
HISTFILE: '/home/user/.bash_history'
history
1 echo "to remove"
2 history
3 echo $(test)
4 history
Any ideas on how comes it does not remove the first entry of the history?
echo
? You don't need to echo its output (it does this just fin by itself already), and the command substitution creates a subshell. – Kusalananda Oct 04 '22 at 08:55test
on the command line worked fine. – rellampec Oct 04 '22 at 08:58