Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to recursively grep

13 views
Skip to first unread message

rusi

unread,
Aug 20, 2012, 11:23:57 PM8/20/12
to
I am trying to figure out how to search source trees effectively for
identifiers.
For example I am searching for charset-map-path in the elisp directory
tree

I do
M-x zrgrep
charset-map-path ;; string searched
... in files: I leave the default as *.gz
Base directory: /usr/share/emacs/23.4/lisp/


-*- mode: grep; default-directory: "/usr/share/emacs/23.4/lisp/" -*-
Grep started at Tue Aug 21 08:35:08

find . \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/
MCVS -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path
\*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -
prune -o \( -name .\#\* -o -name \*.o -o -name \*\~ -o -name \*.bin -o
-name \*.lbin -o -name \*.so -o -name \*.a -o -name \*.ln -o -name
\*.blg -o -name \*.bbl -o -name \*.elc -o -name \*.lof -o -name \*.glo
-o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -
name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name
\*.x86f -o -name \*.sparcf -o -name \*.fasl -o -name \*.ufsl -o -name
\*.fsl -o -name \*.dxl -o -name \*.pfsl -o -name \*.dfsl -o -name
\*.p64fsl -o -name \*.d64fsl -o -name \*.dx64fsl -o -name \*.lo -o -
name \*.la -o -name \*.gmo -o -name \*.mo -o -name \*.toc -o -name
\*.aux -o -name \*.cp -o -name \*.fn -o -name \*.ky -o -name \*.pg -o -
name \*.tp -o -name \*.vr -o -name \*.cps -o -name \*.fns -o -name
\*.kys -o -name \*.pgs -o -name \*.tps -o -name \*.vrs -o -name \*.pyc
-o -name \*.pyo \) -prune -o -type f \( -name \*.gz \) -print0 |
"xargs" -0 -e zgrep -i -nH -e charset-map-path
./cus-start.el.gz:106: (charset-map-path installation

Grep exited abnormally with code 123 at Tue Aug 21 08:35:29

So it found the occurrence in cus-start.el and stopped abnormally.
Run it a second time and it does finds nothing.

What am I doing wrong?

Peter Dyballa

unread,
Aug 21, 2012, 4:14:34 AM8/21/12
to rusi, help-gn...@gnu.org

Am 21.08.2012 um 05:23 schrieb rusi:

> What am I doing wrong?

Are you searching at all? Your pages long find command seems to just exclude instead of searching…

In which files do you think the string "charset-map-path" will occur? Then search for these files only:

M-x find-grep RET
<insert the search string at the cursor position>
<insert '-name "*.el.gz ' appropriately>
<adjust where the search will start, if needed>
<adjust the grep command to deal with compressed files>
RET

It also works to search in C source files with '-name "*.[ch]"'.

--
Greetings

Pete

The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny..."
– Isaac Asimov


rusi

unread,
Aug 21, 2012, 8:47:52 AM8/21/12
to
On Aug 21, 1:14 pm, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
> Am 21.08.2012 um 05:23 schrieb rusi:
>
> > What am I doing wrong?
>
> Are you searching at all? Your pages long find command seems to just exclude instead of searching…
>
> In which files do you think the string "charset-map-path" will occur? Then search for these files only:
>
>         M-x find-grep RET
>         <insert the search string at the cursor position>
>         <insert '-name "*.el.gz ' appropriately>
>         <adjust where the search will start, if needed>
>         <adjust the grep command to deal with compressed files>
>         RET
>
> It also works to search in C source files with '-name "*.[ch]"'.


So you are saying dont use zrgrep but use find-grep?

Peter Dyballa

unread,
Aug 21, 2012, 9:46:16 AM8/21/12
to rusi, help-gn...@gnu.org

Am 21.08.2012 um 14:47 schrieb rusi:

> So you are saying dont use zrgrep but use find-grep?

Yes, I feel better when I can control things. (Maybe I am also missing enough compressed files.) Both functions are in grep.el.

--
Greetings

Pete

With Capitalism man exploits man. With communism it's the exact opposite.


0 new messages