Emacs: finding a regex buffer and displaying results in a new buffer?

Suppose I had a buffer in emacs with 1000 lines, and Unicode links were marked in this buffer (for example, \u8226 ). I want to collect all these links into another buffer, which I can then sort and identify.

On the command line (* nix), I can do something like:

 grep -o "\\\\u[0-9]*" tmpfile | sort | uniq 

Is this achievable directly inside emacs without saving any buffers to disk?

+4
source share
2 answers

Go to the buffer, select everything with Cx h , then do M-| grep -o "\\\\u[0-9]*" | sort | uniq M-| grep -o "\\\\u[0-9]*" | sort | uniq M-| grep -o "\\\\u[0-9]*" | sort | uniq (this is done by shell-command-on-region ). The output will go to *Shell Command Output* , which will not be displayed if the output is not long enough, but it is always created, and you can switch to it independently.

There is also occur ( Ms o ).

+6
source
 Mx occur RET [[:nonascii:]]+ RET Mx other-window Mx toggle-read-only Mx sort-lines 
+6
source

All Articles