Editing a previous command line

You can edit any previous command from the history list to create a new command. Suppose that command number 23 in the history list is:

   23 lpr part[1-4].ps

Do a preview of the command if you are not sure that it is the right one.

To change [1-4] to [5-8]use the command:

   !23:s/[1-4]/[5-8]/

This will now run the command:

   lpr part[5-8].ps

Another way to edit commands in the history list is to move up and down the list until you find the command you are looking for and then edit its command line.


[Home] [Search] [Index] This site maintained by unixhelp@ed.ac.uk