Wed 13 Jul 2011 11:56:25 PM UTC, original submission:
Peter Samuelson has submitted a patch to Debian to modify the behavior of `grep -lc'. Copying what he wrote in http://bugs.debian.org/76011
-----------------------------------------------------------------
Okay, grep has two very useful options, -l and -c:
-l, --files-with-matches only print FILE names containing matches
-c, --count only print a count of matching lines per FILE
It seems only logical that 'grep -lc' would count the matching lines per file, but skip files with no matches. Obvious, right? (: But the status quo is that 'grep -lc' gives garbled output from both options, i.e. "undefined behavior".
Fortunately, it's a simple change. Would seven lines of source bloat be considered unacceptible? Note that this change isn't just for theoretical consistency -- I find it very practical. Because otherwise I am forever saying
grep -c ..... | grep -v :0
-----------------------------------------------------------------
I think his patch is correct and useful. Could you please consider this patch?
Thanks,
Santiago
|