|
There are a number of shortcuts available to make
your UNIX time more productive. Aliases allow you to create a
command that executes another command, or set of commands, that
you frequently type. For example, you could create the m
command which types more for you. So now to view files
you would type m filename as opposed to more
filename. This saves a few keystrokes. There may be
other situations in which you want to specify new commands that
you are used to in another environment, for example, replacing
cp with copy as in the DOS environment. To create
an alias, type alias new_command old_command. It is a
good idea to store your aliases is in your .cshrc file.
alias
List defined aliases.
alias dir ls -F
Define the alias dir as the command ls -F.
alias del rm
Define the alias del as the command rm.
alias copy cp
Define the alias copy as the command cp.
Another useful shortcut is the bang operator (!)
or exclamation point. You can use this special character to
retype a line or portion of a line that you have previously
typed either just before this command line or further back in
the history of your work in UNIX. You can use the history
command to list the last 20 or so commands that you have
recently typed with a historical number next to each command.
Typing !! it repeats the last command you
entered. If you type !num it will repeat the num-th
command in your history. Also, using the !num
command, you can specify a negative number which will retype the
command num commands before the present one. !char
looks for the last command starting with that character and
retypes it. You may include more than one character to narrow
down the search. Lastly, you may specify portions of a command
to repeat. !:num will repeat the num-th parameter
on the last command line. To repeat all of the parameters except
the first you use !:*. Some examples follow:
echo a b c d e f
Display the characters a b c d e f.
!!
Repeat the previous command ( echo a b c d e f ).
clear
Clear the screen.
echo !:4
Display the character d.
echo a b c d e f
Display the characters a b c d e
f.
echo !:*
Display the characters a b c d e f (all of the
parameters of the previous command).
history
Display all of the commands starting with the first echo.
!c
Repeat the clear screen command. |