I'm surprised I was unable to find this anywhere, so I am sorry if I haven't searched enough.
I want to run a bash script, but have its command erased from the history without changing any settings outside of the script.
I have tried in the bash file
history -d $((HISTCMD))
as HISTCMD
gives the correct row number, but when run in the bash it isn't working.
Any ideas?
Can't be done. Sorry.
The bash process that's running as your interactive shell, and the bash process that interprets your shell script, are different processes. The child (the one running your shell script) cannot affect the settings of the parent (the one that maintains the history).