M-! runs the command
shell-command. This will prompt you for the actual command to run in the minibuffer, which then runs. You can run it in the background by putting a
& at the end, just as you would in a terminal. alternatively, you can use
The output from the shell command will be placed in a temporary buffer. If you want it inserted in the current buffer, use a prefix argument. (i.e.,
A very useful related function is
shell-command-on-region, bound to
M-| by default. This will run a shell command on the contents of the region. The output will go in a temporary buffer, or, as with
M-!, if you use a prefix argument the selected region will be replaced by the output of the shell command.
See (emacs) Single Shell in the manual for more details.