I followed https://unix.stackexchange.com/a/43460/674: after

$ locate -i linux | less

I type g|$emacs - in less, but nothing is opened in Emacs, and the terminals says:

emacs: standard input is not a tty

What does that mean?

g|$emacs -nw - doesn't work either. Btw, I want to use emacs in terminal not its GUI.

what shall I do then?

  • Isn't it supposed to be a g instead of a q before that pipe?
    – user43791
    May 26, 2015 at 21:46
  • are you trying to run less in e-shell?
    – VaTo
    May 26, 2015 at 21:46
  • The accepted answer on that question says to save the file from less and then open it in emacs. It doesn't look like that is what you are trying here, so which method are you attempting to use? May 26, 2015 at 21:47
  • @KlaatuvonSchlacker The last answer of that thread uses vim in a similar way and it works! ;)
    – user43791
    May 26, 2015 at 21:50
  • 1
    Well, it seems that vim beats emacs on that topic : if this is right, emacs can't read from stdin.
    – user43791
    May 26, 2015 at 21:54

4 Answers 4


Try locate ... > file && emacs file or try locate -i linux > file && emacs file or try locate -i linux > file && emacs file.

Assuming you want to name your temp file "file" or go into emacs and do m-x shell ret then locate -i linux ret or m-x locate ret.


The accepted answer of the thread you linked to is correct (as are the other answers in this thread).

To summarize for anyone coming to this thread from google, the OP referred to this particular answer in the linked thread which used the g|$vim - command inside less to pipe all of less's content to vim's stdin channel.

However, based on answers from this thread, it doesn't seem to be possible to read text from stdin in emacs, which is why the answer to this question is to output to a temporary file when one is determined to use emacs instead of vim.


See this Question on StackOverflow: Pipe less to Emacs - in particular see the answer by event_jr, where he refers to a package he made: e-sink. A brief description is – Pipe output of shell command into a Emacs buffer using emacsclient.

I believe that emacsclient does work for the terminal version of emacs

I use e-sink (in the GUI version) every day and love it – though, to suit my usage needs, I modified it slightly to erase the buffer on each invocation.


There is no way to construct a buffer from std in with emacs. You could do the reverse and launch locate and less from within emacs, but not the other way round.

Otherwise, Saul's idea (and the accepted answer in the post you cite) are correct; save the output to a file and open that within emacs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .