Some UNIX commands, usually interactive commands like
, let you run
another UNIX command temporarily.
To do that, you type a special command character - usually an exclamation
)-then type the UNIX command line you want to run.
In this article, I'll show examples for the
To see if this works on another utility, check its documentation or just try
when the utility is waiting for you to
type a command.
You can run any UNIX command without quitting
. That's handy, for
example, if you want to read your mail or look at some other file...
then go back to the file you were editing without losing your place.
It's called a "shell escape."
(By the way, there's a another way to do this, called
job control (
that works on many UNIX systems with most of their shells.
I think that job control is a lot more convenient and flexible than
Let's say you're editing the file named
and you need to run
to get someone's phone number from your phone file. The steps are:
Be sure you're in command mode (press the
key if you aren't sure).
If you want to run a command that needs the file you're editing,
remember to write out your
buffer with the
(So, you probably wouldn't need to write before the
followed by the UNIX command, then press
program will run. When it finishes,
[Hit return to continue]
After you press
you'll be right back where you were.
on your screen.
Run this file through the
with the name of the file you're editing now.
Read your mail.
Be careful about this if you were already running the
you used the command
to edit a message with
This shell escape starts a
take you back to
session before you started editing!
Start a completely new shell.
(If you are using a shell with job control, you'll almost always want to use job control
Basically: anything you can do at a shell prompt, you can do with a shell
You'll be in a
though, not your original login shell.
So, commands like
won't affect the program where you started the
subshell or any other shell.
On the bright side, changing directories or resetting anything in
your environment won't affect
or the shell where you started
Terminating the program you're running in the subshell
will bring you right back where you were.