I was expanding my programming horizons over the
weekend and ran across this article about awk at
http://www.linux.com/articles/114109
"The power of awk comes from how much it does automatically for you when
crunching text files, and from the simple elegance of the language. When you
feed awk a text file, it does the following:
a.. Opens and reads all input files listed on the command line
b.. Handles memory management for all variables
c.. Parses each line and splits it into fields using the field separator
d.. Presents each line of text to your program as variable $0
e.. Presents each field from each line in predefined variables, starting
with $1, $2, ... $N
f.. Maintains many internal variables for your use, such as (but not
limited to):
a.. RS = record separator
b.. FS = field separator
c.. NF = number of fields in the current record
d.. NR = number of records processed so far
g.. Automatically handles conversion between internal data types (string,
floating point, array)
h.. Executes the BEGIN block before processing any records (a good place
to initialize variables)
i.. Executes the END block after processing all records (a good place to
calculate report totals)
j.. Closes all input files listed on the command line"
I really envy those *nix guys. Can you imagine the power
and ease of use that would result from having some sort
of automatic way do all this in RPG?
(For the humor impaired - I know this is exactly what the
cycle does in RPG. I just got a kick out of finding a feature
RPG has had for 44 years described so well.)
Lance
As an Amazon Associate we earn from qualifying purchases.