ABOUT cLIeNUX /source/script/awk/

awk is a programming language that in many ways picks up where the shell
leaves off. The shell is geared to dealing with whole files. The contents
of files are difficult to process with the shell itself. If the job at
hand involves processing a file on e.g. a line-by-line basis, the shell
usually calls a command for the type of processing needed. If the type of
processing isn't available from a command, you may have an awk scripting
situation on your hands. Of the programming languages in cLIeNUX Core, one
could rank them from highest-abstraction to lowest as...  

Bash        sed        dcon chat  awk                     Gforth C   asm
                 (Perl)    

Perl is shown for comparison, although it's not in cLIeNUX Core. This is
an abstraction scale. What's not shown here is feature-richness. Perl has
sockets and other goodies that are not available in awk, and dcon and chat
are tiny little languages, but the simplest data object in Perl is more
abstract than the ints and floats available in dcon and awk. For
feature-richness Perl would be listed over by C, and awk would be about
half-way between sed and Perl.  Asm means machine code, zero abstraction.
With zero abstraction one also loses inter-CPU portability.

awk can loop over a file line-by-line like sed, and use regexes as
"addresses"  for which lines to process, but it also has the BEGIN and END
"patterns"  which allow program flow-control independant of data file
lines, and a full set of standard programming flow-control constructs for
loops, branches, subroutines (functions) and so on. awk also has familiar
file IO mechanisms like redirection, various print functions, string
functions, floating point math with a nice set of math functions, and
other things that allow a programming language to act like a computer and
not a mere special-purpose service to some specific data object like a
text file.  Even so, awk can be called for simple stuff without a lot of
baggage when appropriate almost as easily as scan/grep. 

Since awk is more geared for regular procedural programming, the syntax to
do regular procedural programming is much cleaner than the shell, and
somewhat cleaner than Perl.

When Bash is just not wanting to do what you want, look into awk. 


Copyright 1999 Rick Hohensee (Richard Allen Hohensee)  

This file is released for redistribution only as part of an intact entire
cLIeNUX Core.

