Hot answers tagged

6 votes
Accepted

Using pipe in a shell command

By default, dired-do-shell-command inserts the file name at the end of the command you enter. In effect, you are doing this: tac | head -n 2 test Without an argument, tac doesn't produce any output ...
user avatar
  • 20.3k
2 votes
Accepted

Non-shell command on region?

I figured it out. It turns out that I can send input to a process invoked via start-process, and so I don't need to use call-process at all. Since start-process doesn't invoke the specified command ...
user avatar
  • 522
2 votes

How to "pipe" a string to a shell command in elisp rather than give it as an arg?

Correct. In a shell like Bash, the pipe character | forwards the output of the command on the left into the input of the command on the right. Whatever the first command prints to file descriptor 1 (...
user avatar
  • 11.7k
2 votes

How to "pipe" a string to a shell command in elisp rather than give it as an arg?

See shell-command-on-region (suggestively bound to M-|). You can select a region and call shell-command-on-region, specifying the readability command. The region becomes the standard input for the ...
user avatar
  • 19.9k
2 votes
Accepted

how to execute shell command with piping in Elisp?

The shell handles the pipelines, so there's no reason why the command you give shell-command-to-string can't include pipes. (shell-command-to-string "curl 'https://google.com' 2>/dev/null | wc&...
user avatar
  • 43.5k
2 votes

How to pipe data through multiple processes?

Use the system shell, e.g., M-! ls | wc, there are many other APIs such as shell-command-to-string, call-process-shell-command and start-process-shell-command. An idea is emulating pipe like the ...
user avatar
  • 13.6k
2 votes
Accepted

Piping contents of buffer into eshell command

You can use M-| (shell-command-on-region). Within eshell, you can use ~ $ (with-current-buffer "*scratch*" (buffer-string)) | nl 1 ;; This buffer is for text that is not saved, and for Lisp ...
user avatar
  • 13.6k
1 vote

Slurp standard-input into a buffer

Read /dev/stdin, e.g., $ date -u | emacs --batch --eval '(insert-file-contents "/dev/stdin")' --eval '(princ (buffer-string))' Thu Nov 28 19:12:02 UTC 2019 Not sure about Windows though.
user avatar
  • 13.6k
1 vote

Slurp standard-input into a buffer

After a bit of research, apparently this is the best we can do right now: #! /usr/bin/env emacs --script (defun slurp-stdin () (condition-case nil (while t (insert (read-from-minibuffer "") "\n")) ...
user avatar
  • 357

Only top scored, non community-wiki answers of a minimum length are eligible