summaryrefslogtreecommitdiff
path: root/devdocs/bash/event-designators.html
blob: b5f38cbb896ceb614ac3e0fb1782dce314c6117e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<h1 class="subsection">Event Designators</h1>  <p>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.  </p> <dl compact> <dt><span><code>!</code></span></dt> <dd>
<p>Start a history substitution, except when followed by a space, tab, the end of the line, ‘<samp>=</samp>’ or ‘<samp>(</samp>’ (when the <code>extglob</code> shell option is enabled using the <code>shopt</code> builtin). </p> </dd> <dt><span><code>!<var>n</var></code></span></dt> <dd>
<p>Refer to command line <var>n</var>. </p> </dd> <dt><span><code>!-<var>n</var></code></span></dt> <dd>
<p>Refer to the command <var>n</var> lines back. </p> </dd> <dt><span><code>!!</code></span></dt> <dd>
<p>Refer to the previous command. This is a synonym for ‘<samp>!-1</samp>’. </p> </dd> <dt><span><code>!<var>string</var></code></span></dt> <dd>
<p>Refer to the most recent command preceding the current position in the history list starting with <var>string</var>. </p> </dd> <dt><span><code>!?<var>string</var>[?]</code></span></dt> <dd>
<p>Refer to the most recent command preceding the current position in the history list containing <var>string</var>. The trailing ‘<samp>?</samp>’ may be omitted if the <var>string</var> is followed immediately by a newline. If <var>string</var> is missing, the string from the most recent search is used; it is an error if there is no previous search string. </p> </dd> <dt><span><code>^<var>string1</var>^<var>string2</var>^</code></span></dt> <dd>
<p>Quick Substitution. Repeat the last command, replacing <var>string1</var> with <var>string2</var>. Equivalent to <code>!!:s^<var>string1</var>^<var>string2</var>^</code>. </p> </dd> <dt><span><code>!#</code></span></dt> <dd>
<p>The entire command line typed so far. </p> </dd> </dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>Licensed under the GNU Free Documentation License.<br>
    <a href="https://www.gnu.org/software/bash/manual/html_node/Event-Designators.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Event-Designators.html</a>
  </p>
</div>