views:

58

answers:

2

I use Alt-! (Alt-Bang) a lot in Emacs. One of the big things I use it for is

Alt-! cat $logfile | grep 'this' # show me one kind of event

or sometimes

Alt-! cat $logfile | grep 'this' | wc -l # count that one event's occurrences

Two things:

1) No tab-completion from this prompt: why not?

2) What if instead of $logfile, I want to scan one of the Emacs buffers?

+1  A: 

Alt-| does is shell-command-on-region

with a(ny) numeric prefix (e.g. C-u 1 Alt-|) the region is replaced by the result, otherwise that appears in new buffer

second
n.b. `C-u` provides a default value (4^n when you press `C-u` n times), so when the number is irrelevant, or just needs to be some positive integer, you needn't use `C-u 1` when you can just use `C-u` on its own (or `M-1` or `C-1`).
phils
+3  A: 

To scan an Emacs buffer, use M-| instead of M-!: it passes the region as input to the command. Use M-1 M-| if you want the output of the command to replace the region.

For the particular command you mention, use M-x grep if you want to see all matches. Or you can open it and see the matches with M-x occur.

Gilles