Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: lambda functions in C Date: Sat, 11 Mar 2017 17:23:31 -0800 Organization: None to speak of Lines: 40 Message-ID: References: <7557f1e3-ba5e-4aa9-b0bd-9073e58c7844@googlegroups.com> <8f5734c1-b95e-40ea-8cf3-c0c741b82d00@googlegroups.com> <362dae7c-352a-45e6-9823-53167c45a317@googlegroups.com> <383737e2-fcfc-47c1-acff-7f12fc234b46@googlegroups.com> <66cb9d2d-bae2-47db-a5e0-a2cbc167e871@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="d5c25131a836292d2fdc6aedec13ad15"; logging-data="3856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18M5dHJ1LkbjlZgrh5v9h3P" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:vKAjBVnSTBbze2HQNi/6TGlMGO8= sha1:L+muQAlHnVRFQVt3JRpYVcwxqKg= Xref: csiph.com comp.lang.c:105843 jacobnavia writes: > Le 12/03/2017 à 00:30, jameskuyper@verizon.net a écrit : >> I make extensive use of grep. A command I've issued many times this afternoon was: >> >> grep -l search_string `find . -name "*.cpp" -o -name "*.h"` > > Ahhh very interesting. I didn't thought about that. I used the > recursive option of grep but could not figure out how to avoid binary > files. Your command filters the files, much better... > > Will use that next time. If you use bash with the "globstar" option enabled "shopt -s globstar" (and I think zsh has a similar feature) this can be simplified to: grep -l search_string **/*.{h,c} (Using .c rather than .cpp to make this more nearly topical.) It also deals better with odd characters, particularly spaces, in file and directory names. Either solution can generate a *very* long command line for large source trees, but modern systems and shells typically don't have a problem with that. If it is a problem: find . -name '*.h' -o -name '*.c' -print0 | xargs -0 grep -l search_string assuming your find and xargs commands support these options (the GNU findutils versions do). The "ctags" command can also be useful if you're looking for identifiers rather than more complex patterns (both vim and emacs interface with it). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"