30.26 Shell Escapes: Running One UNIX Command While Using Another
Some UNIX commands, usually interactive commands like vi
, let you run
another UNIX command temporarily.
To do that, you type a special command character - usually an exclamation
point ( You can run any UNIX command without quitting vi . 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 (12.1 ) , that works on many UNIX systems with most of their shells. I think that job control is a lot more convenient and flexible than shell escapes.) Let's say you're editing the file named foo and you need to run grep to get someone's phone number from your phone file. The steps are:
Other examples:
Basically: anything you can do at a shell prompt, you can do with a shell escape. You'll be in a subshell though, not your original login shell. So, commands like cd 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 vi or the shell where you started vi . Terminating the program you're running in the subshell will bring you right back where you were. - |
|