summaryrefslogtreecommitdiff
path: root/devdocs/bash/word-designators.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/bash/word-designators.html
new repository
Diffstat (limited to 'devdocs/bash/word-designators.html')
-rw-r--r--devdocs/bash/word-designators.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/devdocs/bash/word-designators.html b/devdocs/bash/word-designators.html
new file mode 100644
index 00000000..eee5700c
--- /dev/null
+++ b/devdocs/bash/word-designators.html
@@ -0,0 +1,17 @@
+<h1 class="subsection">Word Designators</h1> <p>Word designators are used to select desired words from the event. A ‘<samp>:</samp>’ separates the event specification from the word designator. It may be omitted if the word designator begins with a ‘<samp>^</samp>’, ‘<samp>$</samp>’, ‘<samp>*</samp>’, ‘<samp>-</samp>’, or ‘<samp>%</samp>’. Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero). Words are inserted into the current line separated by single spaces. </p> <p>For example, </p> <dl compact> <dt><span><code>!!</code></span></dt> <dd>
+<p>designates the preceding command. When you type this, the preceding command is repeated in toto. </p> </dd> <dt><span><code>!!:$</code></span></dt> <dd>
+<p>designates the last argument of the preceding command. This may be shortened to <code>!$</code>. </p> </dd> <dt><span><code>!fi:2</code></span></dt> <dd><p>designates the second argument of the most recent command starting with the letters <code>fi</code>. </p></dd> </dl> <p>Here are the word designators: </p> <dl compact> <dt><span><code>0 (zero)</code></span></dt> <dd>
+<p>The <code>0</code>th word. For many applications, this is the command word. </p> </dd> <dt><span><code><var>n</var></code></span></dt> <dd>
+<p>The <var>n</var>th word. </p> </dd> <dt><span><code>^</code></span></dt> <dd>
+<p>The first argument; that is, word 1. </p> </dd> <dt><span><code>$</code></span></dt> <dd>
+<p>The last argument. </p> </dd> <dt><span><code>%</code></span></dt> <dd>
+<p>The first word matched by the most recent ‘<samp>?<var>string</var>?</samp>’ search, if the search string begins with a character that is part of a word. </p> </dd> <dt><span><code><var>x</var>-<var>y</var></code></span></dt> <dd>
+<p>A range of words; ‘<samp>-<var>y</var></samp>’ abbreviates ‘<samp>0-<var>y</var></samp>’. </p> </dd> <dt><span><code>*</code></span></dt> <dd>
+<p>All of the words, except the <code>0</code>th. This is a synonym for ‘<samp>1-$</samp>’. It is not an error to use ‘<samp>*</samp>’ if there is just one word in the event; the empty string is returned in that case. </p> </dd> <dt><span><code><var>x</var>*</code></span></dt> <dd>
+<p>Abbreviates ‘<samp><var>x</var>-$</samp>’ </p> </dd> <dt><span><code><var>x</var>-</code></span></dt> <dd>
+<p>Abbreviates ‘<samp><var>x</var>-$</samp>’ like ‘<samp><var>x</var>*</samp>’, but omits the last word. If ‘<samp>x</samp>’ is missing, it defaults to 0. </p> </dd> </dl> <p>If a word designator is supplied without an event specification, the previous command is used as the event. </p><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/Word-Designators.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Word-Designators.html</a>
+ </p>
+</div>