Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/277171169537445889
deleted 33 characters in body; edited title
Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

How to delete commands in history matching a given string?

I need to delete all commands in my history matching a string. I'veI've tried:

$ history | grep searchstring | cut -d"d" "" -f2 | history -d
 
-bash: history: -d: option requires an argument
 

$ history | grep searchstring | cut -d"d" "" -f2 | xargs history -d
 
xargs: history: No such file or directory
 

$ temparg() { while read i; do "$@""$@" "$i";"$i"; done }
 
$ history | grep searchstring | cut -d"d" "" -f2 | temparg history -d
(no error, but nothing is deleted)

(no error however nothing is deleted)

What is the solutionright way to do this?

How to delete commands in history matching string?

I need to delete all commands in 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 however nothing is deleted)

What is the solution?

How to delete commands in history matching a given string?

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?

Formatting
Source Link
jasonwryan
  • 74.9k
  • 35
  • 204
  • 230

how How to delete commands in history matching string?

I need to delete all commands in 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

history | grep searchstring | cut -d" " -f2 | history -d

-bash: history: -d: option requires an argument

temparg() { while read i; do "$@" "$i"; done }

history | grep searchstring | cut -d" " -f2 | xargs history -d

xargs: history: No such file or directory

history | grep searchstring | cut -d" " -f2 | temparg history -d

temparg() { while read i; do "$@" "$i"; done }

history | grep searchstring | cut -d" " -f2 | temparg history -d

(no error however nothing is deleted)

What is the solution?

how to delete commands in history matching string?

I need to delete all commands in 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 however nothing is deleted)

What is the solution?

How to delete commands in history matching string?

I need to delete all commands in 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 however nothing is deleted)

What is the solution?

Source Link
linuxfix
  • 391
  • 2
  • 4
  • 6
Loading