We have seen how history, !!, !$, and !n can be used to access historical commands or portions thereof. It is, however, also possible to both access and modify the arguments and the command itself of previously issued commands.
Table 1 summarizes the many ways in which entire commands or portions thereof can be referred to in subsequent commands.
Table 1. A summary of referencing previous commands.
Refer to the.. | Refer to the selected argument(s) of the.. | Prepend pre and append end to the.. | Prepend pre and append end to the selected argument(s) of the.. | |
---|---|---|---|---|
..last command | !! | !:mod | pre!!end | pre!{:mod}end |
..nth command | !n | !n:mod | pre!{n}end | pre!{n:mod}end |
..nth most recent command | !-n | !-n:mod | pre!{-n}end | pre!{-n:mod}end |
..last command starting with str | !str | !str:mod | pre!{str}end | pre!{str:mod}end |
..last command starting containing trin | !?trin? | !?trin?:mod | pre!{?trin?}end | pre!{?trin?:mod}end |
Table 2 shows the allowable modifiers (mod) which may be used to select the specific arguments.
Table 2. A summary of command argument selectors.
:0 | the command |
:n | the nth argument |
^ | the first argument* |
$ | the last argument* |
:m-n | the mth through n arguments |
-n | the same as -n* |
:m- | the mth argument through to the second-to-last argument |
:m* | the mth argument through to the last argument* |
* | all the arguments (the same as ^-$)* |
*Note: the colon : can still be used in these case.
Copyright ©2005-2012 by Douglas Wilhelm Harder. All rights reserved.