[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using find-grep in emacs
From: |
Bob Proulx |
Subject: |
Re: using find-grep in emacs |
Date: |
Mon, 13 May 2013 22:45:10 -0600 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
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
Re: using find-grep in emacs, Rami A, 2013/05/15