From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: dkcombs@panix.com (David Combs) Newsgroups: gmane.emacs.help Subject: Re: find string in files Date: Sun, 19 Nov 2006 22:55:46 +0000 (UTC) Organization: Public Access Networks Corp. Message-ID: References: <873b96gm1j.fsf@thalassa.informatimago.com> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1163979631 32360 80.91.229.2 (19 Nov 2006 23:40:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 19 Nov 2006 23:40:31 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 20 00:40:31 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GlwGy-0004wZ-DH for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Nov 2006 00:40:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GlwGx-0005NZ-VM for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2006 18:40:27 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!panix!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 87 Original-NNTP-Posting-Host: panix3.panix.com Original-X-Trace: reader2.panix.com 1163976946 12138 166.84.1.3 (19 Nov 2006 22:55:46 GMT) Original-X-Complaints-To: abuse@panix.com Original-NNTP-Posting-Date: Sun, 19 Nov 2006 22:55:46 +0000 (UTC) X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Original-Xref: shelby.stanford.edu gnu.emacs.help:143213 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:38830 Archived-At: In article <873b96gm1j.fsf@thalassa.informatimago.com>, Pascal Bourguignon wrote: >Gary Wessle writes: > >> how can I have the output of "$ grep -FHwire string path" in a window >> in the same frame with each line hyperlinked so that by placing the >> pointer and it takes me there? > >M-x grep RET (edit the command) grep -FHwire string path RET > > >> this command is just a shell command to find exact string recursively >> in a given path. > >You'll probably want to keep -n (Absolutely keep -n -- that's what emacs uses to go-to that line!) Here's what I do: In *shell*: egrep -in mypattern set-of-files-to-look-in > t.loc (note: you MUST either list TWO-or-more files (so as to get the file-names in the t.loc lines), or accomplish the same via the gnu-egrep option that forces that. Then, do M-x grep and CHANGE the offered grep-stmt to "cat t.loc" and THEN hit . My reason for doing it in these two steps: . Enables me to mess around, make mistakes, retry, etc, the egrep (OR WHATEVER!) to create that t.loc output-file. . The "or whatever!": all emacs cares is that t.loc LOOKS LIKE the result of a grep -n -- ie, has lines of the form: relative-or-absolute-path-name COLON lineNum COLON (optionally!)the-text-at-that-lineNum . about that "(optionally!)the-text..." -- emacs (it seems to me) totally *ignores* that text, relying solely on the target line-number. THUS -- you can do what ever you want to that egrep-found text -- such as when running through some text someone has written, and you want to make sure that the word "which" wasn't used where a "that" would have been better, you can modify your t.loc from, say, foo.txt:100:Now is the time for a good man, which is sorely needed in foo.txt:123:that is the location which I saw yesterday when foo.txt:147:and she was the date which he went to the ... foo.txt:100:Now is the time for a good man, **WHICH** is sorely needed in foo.txt:123:**THAT** is the location **WHICH** I saw yesterday when foo.txt:147:and she was the date **WHICH** he went to the ... , enabling you to easily spot all uses of that and which in *grep* -- yet when you ^C^C on a *grep* line, the corresponding one it goes to, in the actual target file, has *not* been modified. Nifty. Also, I believe I had success when using the egrep options -A and -B, to get surrounding context. And, you can write your own program or script to hunt down interesting places in files -- just so your output t.loc file *appears to emacs* to be output from grep -n. I hope these hints aid others -- they sure have helped me! David