Previous: Programs Summary, Up: Sample Programs [Contents][Index]
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.
id
takes options that control which
information is printed. Modify the awk
version
(see section Printing Out User Information) to accept the same arguments and perform in the
same way.
split.awk
program (see section Splitting a Large File into Pieces) assumes
that letters are contiguous in the character set,
which isn’t true for EBCDIC systems.
Fix this problem.
(Hint: Consider a different way to work through the alphabet,
without relying on ord()
and chr()
.)
FNR
in endfile()
?
Hint: Examine the code in Noting Data file Boundaries.
translate
program
(see section 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
statements for the desired library functions.
Make this change.
sort
utility.
Previous: Programs Summary, Up: Sample Programs [Contents][Index]