grep: add -h (inverse of -H) aswell

This commit is contained in:
Hiltjo Posthuma
2014-11-16 20:03:25 +01:00
committed by sin
parent 7b8d7fb78e
commit f6552e3669
2 changed files with 9 additions and 2 deletions

6
grep.c
View File

@@ -16,6 +16,7 @@ static int grep(FILE *, const char *);
static int eflag = 0;
static int vflag = 0;
static int hflag = 0;
static int Hflag = 0;
static int many;
static char mode = 0;
@@ -54,6 +55,9 @@ main(int argc, char *argv[])
addpattern(EARGF(usage()));
eflag = 1;
break;
case 'h':
hflag = 1;
break;
case 'c':
case 'l':
case 'n':
@@ -145,7 +149,7 @@ grep(FILE *fp, const char *str)
case 'q':
exit(Match);
default:
if (many || Hflag)
if (!hflag && (many || Hflag))
printf("%s:", str);
if (mode == 'n')
printf("%ld:", n);