From: Bob Proulx <bob@proulx.com>
To: help-gnu-emacs@gnu.org
Subject: Re: using find-grep in emacs
Date: Mon, 13 May 2013 22:45:10 -0600 [thread overview]
Message-ID: <20130514044510.GB17139@dismay.proulx.com> (raw)
In-Reply-To: <icbo8ewfsj.fsf@home.home>
Dan Espen wrote:
> Rami A writes:
> > M-x find-grep
> > find . -type f -exec grep -n {} /dev/null \;
What version of emacs are you using? That isn't emacs 23 nor emacs 24.
So what version is it? M-x emacs-version
Specifically "\;" should be "+" in emacs 24.
> > Now I have to change /dev/null to be the directory which I want to search in.
There is a misunderstanding of how that command works. You wouldn't
replace /dev/null. Leave it the same. (Or use -H.)
The string you would want to replace with the directory you want to
search is the "." string not the "/dev/null" string. The "."
specifies the directory to search.
That space between the "-n" and "{}" is where you should type in the
search pattern.
> > How is it possible to not do that every time I use find-grep and
> > that it could remember the directory I am specifying.
> >
> > Also, How to make it default to search all three file types .h .s
> > .c and nothing else?
>
> In emacs 24.2.1 the string is:
>
> find . -type f -print0 | "xargs" -0 -e grep -nH -e
That looks more like emacs 23.2.1 not 24.2.1. Emacs 24.3.1 uses this
string by default:
find . -type f -exec grep -nH -e {} +
^ cursor here
> To only look at .hsc files I'd do:
>
> find . -type f -a -name '*.[hsc]' -exec grep -n {} /dev/null \;
>
> (Not tested but you should get the idea.)
Looks good to me. But also include the pattern. And the -a is superfluous.
find . -type f -name '*.[hsc]' -exec grep -nH PATTERN {} +
> The "." after find is the directory you want to search in, if you don't
> want to search the current directory, replace the ".".
>
> I believe /dev/null is there to convince grep that it should display
> file names because it is looking at multiple files.
Yes. Definitely! :-)
Bob
next prev parent reply other threads:[~2013-05-14 4:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 23:47 using find-grep in emacs Rami A
2013-05-14 0:45 ` Dan Espen
2013-05-14 2:36 ` Barry Margolin
2013-05-14 13:31 ` Ludwig, Mark
2013-05-14 4:45 ` Bob Proulx [this message]
2013-05-14 11:48 ` Andreas Röhler
2013-05-14 15:27 ` Peter Dyballa
2013-05-14 15:42 ` Bob Proulx
2013-05-14 17:19 ` Andreas Röhler
[not found] ` <mailman.25743.1368546134.855.help-gnu-emacs@gnu.org>
2013-05-14 19:41 ` Barry Margolin
2013-05-15 18:25 ` Rami A
2013-05-15 18:49 ` Dan Espen
2013-05-15 18:51 ` Andreas Röhler
[not found] ` <mailman.25858.1368643771.855.help-gnu-emacs@gnu.org>
2013-05-15 19:11 ` Rami A
2013-05-15 19:46 ` Andreas Röhler
2013-05-15 21:23 ` Peter Dyballa
2013-05-16 5:10 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130514044510.GB17139@dismay.proulx.com \
--to=bob@proulx.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.