I want to know if there is a package to send a piece of text to shell commands like sed, awk or other text processing utilities and then get the result back to emacs? Thanks.
1 Answer
Possibly, but there's no need to install a package for this; it's built in.
The command shell-command-on-region
(bound to M-|
by default) prompts for and then executes a shell command, sending it whatever you have selected on stdin, then displays the output in a temporary buffer. With a prefix arg (so C-u M-|
) it replaces the contents of the region with the output of the command.
There are other details in the documentation, so you might want to read it. Type C-h f shell-command-on-region RET
to open a help buffer for the command. This and other commands are also documented in the Emacs manual. C-h i
will open the info viewer with a list of all the available manuals. Select emacs, then navigate to section 40, Running Shell Commands from Emacs. You can jump right to it by typing M-: (info "(emacs)Shell")
, but that's a bit of a mouth-full.