回答:
それはbash歴史の拡張です、例えば
!87
history lineからコマンドを再実行し87ます。
この機能の説明はman bash、「履歴拡張」セクションにあります。
An event designator is a reference to a command line entry in the
history list. Unless the reference is absolute, events are relative to
the current position in the history list.
! Start a history substitution, except when followed by a blank,
newline, carriage return, = or ( (when the extglob shell option
is enabled using the shopt builtin).
!n Refer to command line n.
!-n Refer to the current command minus n.
したがって、最後のコマンドをすばやく呼び出すには!-1、5番目の最後のコマンドを実行し!-5ます。以下のための便利な同義語で!-1ある!!-あなたが例えば呼び出された場合apt install somethingや忘れてしまったsudoだけで実行し、sudo !!あなたにしている良いと。
履歴拡張文字を引用できるのは、バックスラッシュ(\)と一重引用符のみです。
履歴の展開を回避するには、感嘆符をバックスラッシュ(\!)でエスケープするか、単一引用符('!')を使用する必要があります。
!をコマンドに渡し、履歴の展開を回避するには、シングルクォートまたはエスケープする必要があります。 foo '!87'またはfoo \!87。(二重引用符も内容の展開を実行します。)