Bash は前のコマンドを検索して実行します

Bash は前のコマンドを検索して実行します

によるとO'Reily の Bash Pocket Reference (40 ページ)以下は、以下を含む最新のコマンドを実行しますstring:

!?string[?]

上記のコマンドを実行していますが、常に次の結果が返されます:

bash: !?string[?: event not found

これどうやってするの?

答え1

Bash マニュアルより:

!?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.

[?]末尾?がオプションであることを意味します。この規則は、オンラインマニュアルのほとんどの概要セクションで使用されています。たとえば、

NAME
     ls – list directory contents

SYNOPSIS
     ls [-1AaCcdFfgHhikLlmnopqRrSsTtux] [file ...]

関連情報