I need to delete all commands in my history matching a string. I've tried:
$ history | grep searchstring | cut -d" " -f2 | history -d
-bash: history: -d: option requires an argument
$ history | grep searchstring | cut -d" " -f2 | xargs history -d
xargs: history: No such file or directory
$ temparg() { while read i; do "$@" "$i"; done }
$ history | grep searchstring | cut -d" " -f2 | temparg history -d
(no error, but nothing is deleted)
What is the right way to do this?
history -d X
. I came across this question because I had just donehistory | grep search_str | sort -nr | awk '{print $1}' | while read i; do history -d $i; done
. No error, but nothing deleted. Anybody can explain why? – mivk Jun 4 at 17:47