[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] Skip to the content of the web site.

Manipulating the History of Commands

Contents Previous Topic Next Topic

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.

:0the command
:nthe nth argument
^the first argument*
$the last argument*
:m-nthe mth through n arguments
-nthe 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.

Contents Previous Topic Next Topic

Copyright ©2005-2008 by Douglas Wilhelm Harder. All rights reserved.

[an error occurred while processing this directive]