On Fri, Oct 03, 2014 at 10:38:18AM +0200, Mercier Ivan wrote: > Hi, > to work the pattern should be on the same line... > is it normal?how can I can grep in all lines? > I thought --all-match does it!? > > > My test: > mkdir test > cd test > git init > echo -e "titi\ntoto" > file1 > git add -A > git grep -l --all-match -e toto --and --not -e titi gives me file1 > > echo -e "titi toto" > file1 > git grep -l --all-match -e toto --and --not -e titi returns me nothing, > which is correct
Ah, then I understand what you mean. The tool `grep` print lines matching a pattern. It's entirely expected that `git grep` also print lines matching a pattern (otherwise it would be badly named). There are tools that can handle patterns that span line, but `grep` can't[1]. That's not exactly what you want though, you want a `grep` that considers the pattern across the whole file. There are tricks to do that[2]. /M [1]: http://stackoverflow.com/questions/2686147/how-to-find-patterns-across-multiple-lines-using-grep#2686705 [2]: http://stackoverflow.com/questions/4795323/grep-for-multiple-strings-in-file-on-different-lines-ie-whole-file-not-line-b#4795521 -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. -- Alan Kay
pgpLGeBLGkOA1.pgp
Description: PGP signature