Following instructions here:-
https://www.emacswiki.org/emacs/ExecuteExternalCommand
which says:
Using the whole buffer If you are programming using an interpreted language, such as Perl or Python, or a shell script, such as BASH, you might want to run your entire program through the interpreter. To do that, use
C-x h
(mark-whole-buffer
), then useM-|
to send all of the buffer text to the interpreter.
As a simple test I created a new buffer which consisted of:
mkdir /test
then pressed C-x h
followed by M-|
but /test did not get created.
What am I missing?
M-|
is bound to shell-command-on-region, which pipes the region selected through the shell command given in the mini-buffer. Your region text is provided on stdin of the shell command and stdout is shown on the mini buffer. The region and is being replaced by stdout of the shell command if you use the prefix argumanet likeC-U M-|
.wc
as the shell command, and you'll get the idea.mkdir
example,C-x h M-| bash RET
.