C-h f shell-command RET
shell-command is an interactive compiled Lisp function in `simple.el'.
It is bound to M-!, <menu-bar> <tools> <shell>.
(shell-command command &optional output-buffer error-buffer)
Execute string command in inferior shell; display output, if any.
With prefix argument, insert the command's output at point.
If command ends in ampersand, execute it asynchronously.
The output appears in the buffer `*Async Shell Command*'.
That buffer is in shell mode.
Otherwise, command is executed synchronously. The output appears in
the buffer `*Shell Command Output*'. If the output is short enough to
display in the echo area (which is determined by the variables
`resize-mini-windows' and `max-mini-window-height'), it is shown
there, but it is nonetheless available in buffer `*Shell Command
Output*' even though that buffer is not automatically displayed.
To specify a coding system for converting non-ASCII characters
in the shell command output, use C-x RET c
before this command.
Noninteractive callers can specify coding systems by binding
`coding-system-for-read' and `coding-system-for-write'.
The optional second argument output-buffer, if non-nil,
says to put the output in some other buffer.
If output-buffer is a buffer or buffer name, put the output there.
If output-buffer is not a buffer and not nil,
insert output in current buffer. (This cannot be done asynchronously.)
In either case, the output is inserted after point (leaving mark after it).
If the command terminates without error, but generates output,
and you did not specify "insert it in the current buffer",
the output can be displayed in the echo area or in its buffer.
If the output is short enough to display in the echo area
(determined by the variable `max-mini-window-height' if
`resize-mini-windows' is non-nil), it is shown there. Otherwise,
the buffer containing the output is displayed.
If there is output and an error, and you did not specify "insert it
in the current buffer", a message about the error goes at the end
of the output.
If there is no output, or if output is inserted in the current buffer,
then `*Shell Command Output*' is deleted.