grep: add -h (inverse of -H) aswell
This commit is contained in:
parent
7b8d7fb78e
commit
f6552e3669
5
grep.1
5
grep.1
|
@ -3,7 +3,7 @@
|
||||||
grep \- search files for a pattern
|
grep \- search files for a pattern
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B grep
|
.B grep
|
||||||
.RB [ \-EHcilnqv ]
|
.RB [ \-EHchilnqv ]
|
||||||
.RB [ \-e
|
.RB [ \-e
|
||||||
.I pattern ]
|
.I pattern ]
|
||||||
.I pattern
|
.I pattern
|
||||||
|
@ -38,6 +38,9 @@ This option is most useful when multiple -e options are used to
|
||||||
specify multiple patterns, or when a pattern begins with a dash
|
specify multiple patterns, or when a pattern begins with a dash
|
||||||
(`-').
|
(`-').
|
||||||
.TP
|
.TP
|
||||||
|
.B \-h
|
||||||
|
do not prefix each line with 'filename:' prefix.
|
||||||
|
.TP
|
||||||
.B \-i
|
.B \-i
|
||||||
matches lines case insensitively.
|
matches lines case insensitively.
|
||||||
.TP
|
.TP
|
||||||
|
|
6
grep.c
6
grep.c
|
@ -16,6 +16,7 @@ static int grep(FILE *, const char *);
|
||||||
|
|
||||||
static int eflag = 0;
|
static int eflag = 0;
|
||||||
static int vflag = 0;
|
static int vflag = 0;
|
||||||
|
static int hflag = 0;
|
||||||
static int Hflag = 0;
|
static int Hflag = 0;
|
||||||
static int many;
|
static int many;
|
||||||
static char mode = 0;
|
static char mode = 0;
|
||||||
|
@ -54,6 +55,9 @@ main(int argc, char *argv[])
|
||||||
addpattern(EARGF(usage()));
|
addpattern(EARGF(usage()));
|
||||||
eflag = 1;
|
eflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
hflag = 1;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'n':
|
case 'n':
|
||||||
|
@ -145,7 +149,7 @@ grep(FILE *fp, const char *str)
|
||||||
case 'q':
|
case 'q':
|
||||||
exit(Match);
|
exit(Match);
|
||||||
default:
|
default:
|
||||||
if (many || Hflag)
|
if (!hflag && (many || Hflag))
|
||||||
printf("%s:", str);
|
printf("%s:", str);
|
||||||
if (mode == 'n')
|
if (mode == 'n')
|
||||||
printf("%ld:", n);
|
printf("%ld:", n);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user