This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Easy, quick, BASH question


Cliff,

Yes, it's off-topic, but I see no reason to simply send people away for that reason when I have information that might be useful.

As to the "find" part being unnecessary, you don't know that. I assume the reason Kevin originally included the "find" in his attempt is that he wanted to grep in files (of the stipulated name patterns) in the current directory or anywhere beneath it. What you're suggesting will find only those files in the current directory.

It's also possible to use grep's (GNU grep's) -R option in combination with the "--include" argument to select files with the proper name pattern. In this case, this is probably the best way to go in terms of overhead and almost certainly will yield the best net performance.

Randall Schulz
Mountain View, CA USA


At 16:44 2002-08-02, Cliff Hones wrote:
>...
> To get anything more complicated, you must use a shell procedure. E.g.:
>
> hcgrep() {
>          grep -n "$@" $(find -name '*.[ch]')
> }
>
>...

In this particular example, find isn't necessary.  Try:

   hcgrep() { grep -n "$@" *.c *.h"; }

BTW, this is really OT for this list, since it's a Bash question and not
Cygwin-specific.

-- Cliff

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]