1
# egrep.awk --- simulate egrep in awk
2
# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
7
# -s silent - use exit value
8
# -v invert test, success if no match
10
# -l print filenames only
11
# -e argument is pattern
14
while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) {
31
pattern = ARGV[Optind++]
33
for (i = 1; i < Optind; i++)
38
} else if (ARGC - Optind > 1)
42
# pattern = tolower(pattern)
48
function beginfile(junk)
52
function endfile(file)
54
if (! no_print && count_only)
63
matches = ($0 ~ pattern)
67
fcount += matches # 1 or 0
72
if (no_print && ! count_only)
75
if (filenames_only && ! count_only) {
80
if (do_filenames && ! count_only)
82
else if (! count_only)
93
e = "Usage: egrep [-csvil] [-e pat] [files ...]"
94
print e > "/dev/stderr"