grep -r *.java doesn't work as expected

Randall R Schulz rrschulz@cris.com
Sun Jan 19 17:44:00 GMT 2003


Wai-Yip,

Grep _will_ search in files found throughout a directory hierarchy, but 
that's not it's default mode of operation. Look into the "-R" / "-r" / 
"--recursive" option and the associated "--include" and "--exclude" options.

Also, I don't know what you intend by your use of "-m", but according to 
the help output, it requires a numeric argument that limits the number of 
matches displayed per target file.

I suspect that in part you're accustomed to a non-Gnu grep program, and 
there are considerable differences between other greps and Gnu grep. Read 
the man page so you'll know how to use it properly.

Randall Schulz


At 07:04 2003-01-19, Wai-Yip Tung \(wtung\) wrote:
>I try to grep all .java file recursively
>
>[/q/Workflow/AppAdmin/src/com/cisco/wf/admin] $ grep -rn systemRsrc
>*.java
>LDAPConfig.java:948:  ... getRemoteSubsystemRsrcMgr()
>TestLDAPConfig.java:58:    ... getRemoteSubsystemRsrcMgr...
>
>Only files in the current directory is searched.
>
>Interesting when I use only * I search recursively.
>
>[/q/Workflow/AppAdmin/src/com/cisco/wf/admin] $ grep -rn systemRsrc  *
>LDAPConfig.java:948:  public RemoteRsrcMgr getRemoteSubsystemRsrcMgr()
>LDAPConfig.java.keep:928:  public ... getRemoteSubsystemRsrcMgr()
>TestLDAPConfig.java:58:    public ... getRemoteSubsystemRsrcMgr() ..
>iaq/LDAPIAQWebConfig.java:343: ...
>myLDAPConfig.getRemoteSubsystemRsrcMgr();
>iaq/LDAPIAQWebConfig.java:383: ...
>myLDAPConfig.getRemoteSubsystemRsrcMgr();
>
>Problem is it included some non java file. What's wrong?
>
>Wai Yip Tung


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list