1

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 1

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.