歴史的なコマンド!#の機能は何ですか?

歴史的なコマンド!#の機能は何ですか?

マニュアルページからhistory

イベントインジケータイベントインジケータは、履歴リストのコマンドラインエントリへの参照です。参照が絶対的でない場合、イベントは履歴リストの現在の場所に基づいています。

   !      Start a history substitution, except when followed by  a  blank,
          newline, = or (.
   !n     Refer to command line n.
   !-n    Refer to the current command minus n.
   !!     Refer to the previous command.  This is a synonym for `!-1'.
   !string
          Refer  to the most recent command preceding the current position
          in the history list starting with string.
   !?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.
   ^string1^string2^
          Quick substitution.  Repeat the last command, replacing  string1
          with string2.  Equivalent to ``!!:s/string1/string2/'' (see Mod‐
          ifiers below).
   !#     The entire command line typed so far.

!#他のすべては意味がありますが、文脈上の使用法を理解することはできません。どのような役割を果たし、一般的にどのように使用されますか?

ベストアンサー1

ここに答えてください:!#:3はシェルコマンドで何を意味しますか?

デフォルトでは、これを ':n' とともに使用してコマンドを短縮できます。

$ cd /home/me/some/super/deep/dir/that/i/do/not/want/to/type/again ; ll !#:2 

もちろん、これはできるので少し愚かな例ですが、llshスクリプトで使用できることを理解します。

おすすめ記事