How to pipe the selected content in Emacs' buffer to external bash script and then print its output? The script can read data from pipe.
To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab. Emacs fills in the rest of the name.
You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size. When used with a prefix argument (e.g, ` C-u M-!
To execute a file of Emacs Lisp code, use M-x load-file . This command reads a file name using the minibuffer and then executes the contents of that file as Lisp code. It is not necessary to visit the file first; in any case, this command reads the file as found on disk, not text in an Emacs buffer.
Use shell-command-on-region
which is bound to M-|
e.g.:
M-| sort | uniq -c
RET
With a prefix argument, the region is replaced by the output of the shell command (which effectively adds all shell commands to Emacs' editing toolkit; very useful when you know how to do something outside of Emacs, but don't know an equivalent native function).
C-uM-| sort | uniq -c
RET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With