Like the Korn shell, the C shell offers
additional features for repeating and editing previously entered
command lines. Figure
shows an example using the history
command-line number 32 from the previous history file output (cd
home/user2/practice). Figure
shows options available with the history
command. The Bourne shell does not offer these features for editing
previously entered commands.
!!
- Use the double
exclamation marks (!!) to execute the most recent command exactly
as it was executed previously. If you entered lpstat, sent some
print jobs from other terminal windows, and want to enter the
lpstat command again from the original terminal window, type !! at
the shell prompt to execute lpstat the second time as shown in the
first example in Figure .
!*
- Use the exclamation mark
(!) and asterisk (*) to repeat all arguments of the previous
command as shown in Figure ,
example 2.
!$
- Use the exclamation mark
(!) and dollar sign ($) to repeat the last argument of the
previous command as shown in Figure ,
examples 3 and 4.
!number
- Use the exclamation
mark (!) followed by a command number to repeat a specific command
from the command list as shown in Figure
example 5.
!n:p
- Allows you to see a
previous command but not execute it. This is useful for editing
the command which is covered later in this chapter.
Interactive
Media Activity (Flash,
102 kB)
Using
History and Re-Executing Command with the C
Shell
In
this media activity, you are logged in as
user2 and your current working directory is:
/home/user2. Type the commands that would
accomplish the requested objectives. Note: Be
sure to press enter after each one. Click on
step 1 to begin.