diff options
-rw-r--r-- | findutils/grep.c | 5 | ||||
-rw-r--r-- | grep.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 03cc9f836..3254868be 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -179,7 +179,10 @@ static void grep_file(FILE *file) | |||
179 | if (print_match_counts) { | 179 | if (print_match_counts) { |
180 | if (print_filename) | 180 | if (print_filename) |
181 | printf("%s:", cur_file); | 181 | printf("%s:", cur_file); |
182 | printf("%d\n", nmatches); | 182 | if (print_files_with_matches && nmatches > 0) |
183 | printf("1\n"); | ||
184 | else | ||
185 | printf("%d\n", nmatches); | ||
183 | } | 186 | } |
184 | 187 | ||
185 | /* grep -l: print just the filename, but only if we grepped the line in the file */ | 188 | /* grep -l: print just the filename, but only if we grepped the line in the file */ |
@@ -179,7 +179,10 @@ static void grep_file(FILE *file) | |||
179 | if (print_match_counts) { | 179 | if (print_match_counts) { |
180 | if (print_filename) | 180 | if (print_filename) |
181 | printf("%s:", cur_file); | 181 | printf("%s:", cur_file); |
182 | printf("%d\n", nmatches); | 182 | if (print_files_with_matches && nmatches > 0) |
183 | printf("1\n"); | ||
184 | else | ||
185 | printf("%d\n", nmatches); | ||
183 | } | 186 | } |
184 | 187 | ||
185 | /* grep -l: print just the filename, but only if we grepped the line in the file */ | 188 | /* grep -l: print just the filename, but only if we grepped the line in the file */ |