Reputation: 781
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.
Upvotes: 13
Views: 3608
Reputation: 73274
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
Upvotes: 18