diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 01:20:25 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 01:20:25 +0000 |
commit | 2df7eab9da7cf62ca6980328b49886f59f890df9 (patch) | |
tree | 9aec63582e4d5af07f65551c71d05946daab0dc0 /usr.bin/grep/grep.c | |
parent | 1f3b181998b8d4f819e845f3154339a04ed1c4a7 (diff) |
add support for -o to only print the match.
reminded this was useful by ajcoutot
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index e477cf97e3a..eb467d7e352 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.43 2011/03/04 03:11:23 tedu Exp $ */ +/* $OpenBSD: grep.c,v 1.44 2011/07/08 01:20:24 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -74,6 +74,7 @@ int hflag; /* -h: don't print filename headers */ int iflag; /* -i: ignore case */ int lflag; /* -l: only show names of files with matches */ int nflag; /* -n: show line numbers in front of matching lines */ +int oflag; /* -o: print each match */ int qflag; /* -q: quiet mode (don't output anything) */ int sflag; /* -s: silent mode (ignore errors) */ int vflag; /* -v: only show non-matching lines */ @@ -107,9 +108,9 @@ usage(void) { fprintf(stderr, #ifdef NOZ - "usage: %s [-abcEFGHhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n" + "usage: %s [-abcEFGHhIiLlnoqRsUVvwx] [-A num] [-B num] [-C[num]]\n" #else - "usage: %s [-abcEFGHhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n" + "usage: %s [-abcEFGHhIiLlnoqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n" #endif "\t[-e pattern] [-f file] [--binary-files=value] [--context[=num]]\n" "\t[--line-buffered] [pattern] [file ...]\n", __progname); @@ -117,9 +118,9 @@ usage(void) } #ifdef NOZ -static char *optstr = "0123456789A:B:CEFGHILRUVabce:f:hilnqrsuvwxy"; +static char *optstr = "0123456789A:B:CEFGHILRUVabce:f:hilnoqrsuvwxy"; #else -static char *optstr = "0123456789A:B:CEFGHILRUVZabce:f:hilnqrsuvwxy"; +static char *optstr = "0123456789A:B:CEFGHILRUVZabce:f:hilnoqrsuvwxy"; #endif struct option long_options[] = @@ -383,6 +384,9 @@ main(int argc, char *argv[]) case 'n': nflag = 1; break; + case 'o': + oflag = 1; + break; case 'q': qflag = 1; break; |