According to O'Reily's Bash Pocket Reference (page 40) the following will run the most recent command that contains string:
!?string[?]
I'm running said command but I always get back:
bash: !?string[?: event not found
How can I do this?
From the Bash manual:
!?string[?]
Refer to the most recent command preceding the current position
in the history list containing string. The trailing ? may be
omitted if string is followed immediately by a newline.
The [?] means that the trailing ? is optional. You will find this convention used in most synopsis sections in the on-line manuals, for example
NAME
ls – list directory contents
SYNOPSIS
ls [-1AaCcdFfgHhikLlmnopqRrSsTtux] [file ...]