Let's say I have this text in a file:
/home is where the heart is.
If for example, I select the /home text, using C-spc, is there a way of sending it to ls, so that in the end if will execute ls /home? M-| does not work.
As far as I know, there is no way to do that in Emacs directly. But everyting is possible with help of elisp:
(defun region-as-argument-to-command (cmd)
(interactive "sCommand: ")
(shell-command
(format
"%s %s"
cmd
(shell-quote-argument
(buffer-substring (region-beginning)
(region-end))))))
Try
M-| xargs ls. That is, pass "xargs ls" as the shell command on the region selected.
See xargs.
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