split()
with ""
as the separator.
awk
without IGNORECASE
by
using tolower()
on the line and the pattern. In a footnote there,
we also mentioned that this solution has a bug: the translated line is
output, and not the original one. Fix this problem.
grep
accept a -F option which
causes grep
to match fixed strings. Add support for
this to egrep.awk.
grep
allow you to
provide multiple patterns to match, in either of two ways.
You may provide a quoted string on the command line where
the patterns are separated by newlines. Or you may use the
-f option to provide a file containing the patterns,
one per line.
Implement both of these features.
id
takes options that control which
information is printed. Modify the awk
version
(see Printing Out User Information) to accept the same arguments and perform in the
same way.
ord()
and chr()
.)
FNR
in endfile()
?
Hint: Examine the code in Noting Data file Boundaries.
translate
program
(see Transliterating Characters) is painful using standard awk
functions. Given that gawk
can split strings into individual
characters using ""
as the separator, how might you use this
feature to simplify the program?
gawk
had the gensub()
function. Use it
to simplify the code.
BEGIN { pat = ARGV[1] repl = ARGV[2] ARGV[1] = ARGV[2] = "" } { gsub(pat, repl); print }
sed
utility?
getline
in the pathto()
function when testing
for the file’s accessibility for use with the main program simplifies
things considerably. What problem does this engender though?
This file contains a set of default library functions, such
as getopt()
and assert()
.
This file contains library functions that are specific to a site or
installation; i.e., locally developed functions.
Having a separate file allows default.awk to change with
new gawk
releases, without requiring the system administrator to
update it each time by adding the local functions.
One user
suggested that gawk
be modified to automatically read these files
upon startup. Instead, it would be very simple to modify igawk
to do this. Since igawk
can process nested @include
directives, default.awk could simply contain @include
directives for the desired library functions.
Make this change.
sort
utility.